このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

HTMLCanvasElement: webglcontextrestored イベント

Baseline Widely available

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

webglcontextrestoredWebGL API インターフェイスのイベントで、ユーザーエージェントが WebGLRenderingContext オブジェクトの描画バッファーを復元したときに発行されます。

コンテキストが復元されると、コンテキストが失われる前に作成したテクスチャやバッファーなどの WebGL リソースは使えなくなります。WebGL アプリケーションの状態を再初期化し、リソースを再作成する必要があります。

このイベントはバブリングしません。

構文

このイベント名を addEventListener() などのメソッドで使用したり、イベントハンドラープロパティを設定したりしてください。

js
addEventListener("webglcontextrestored", (event) => {}); onwebglcontextrestored = (event) => {}; 

イベント型

WebGLContextEvent です。Event を継承しています。

Event WebGLContextEvent

イベントプロパティ

このインターフェイスには親インターフェイスである Event から継承したプロパティもあります。

WebGLContextEvent.statusMessage

読み取り専用のプロパティで、イベントに関する追加情報を保持します。

WEBGL_lose_context 拡張機能の助けにより、webglcontextrestored イベントをシミュレートすることができます。

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

仕様書

Specification
WebGL Specification
# 5.15.3

ブラウザーの互換性

関連情報