Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. WebGLRenderingContext
  4. canvas

WebGLRenderingContext: canvas property

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⁩.

Note: This feature is available inWeb Workers.

TheWebGLRenderingContext.canvas property is a read-onlyreference to theHTMLCanvasElement orOffscreenCanvasobject that is associated with the context. It might benull if it is notassociated with a<canvas> element or anOffscreenCanvasobject.

Value

Either aHTMLCanvasElement orOffscreenCanvas object ornull.

Examples

Canvas element

Given this<canvas> element:

html
<canvas></canvas>

You can get back a reference to it from theWebGLRenderingContext usingthecanvas property:

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

Offscreen canvas

Example using the experimentalOffscreenCanvas object.

js
const offscreen = new OffscreenCanvas(256, 256);const gl = offscreen.getContext("webgl");gl.canvas; // OffscreenCanvas

Specifications

Specification
WebGL Specification
# DOM-WebGLRenderingContext-canvas

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp