WebGLRenderingContext: drawingBufferWidth プロパティ

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.

WebGLRenderingContext.drawingBufferWidth は読み取り専用のプロパティで、現在の描画バッファーの実際の幅を表します。これは、このコンテキストに関連付けられた <canvas> 要素の width 属性と一致すべきですが、実装がリクエストされた幅を提供できない場合は異なるかもしれません。

数値です。

この <canvas> 要素があったとします。

html
<canvas id="canvas"></canvas>

以下の行で描画バッファーの幅を取得することができます。

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

仕様書

Specification
WebGL Specification
# DOM-WebGLRenderingContext-drawingBufferWidth

ブラウザーの互換性

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
drawingBufferWidth

Legend

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

Full support
Full support

関連情報