recursal/MDN huggingface dataset:
WebGLRenderingContext: checkFramebufferStatus() method
======================================================

 The **`WebGLRenderingContext.checkFramebufferStatus()`** method
 of the WebGL API returns the completeness
 status of the `WebGLFramebuffer` object.

Syntax
------


```js
checkFramebufferStatus(target)
```

### Parameters

`target`

A `GLenum` specifying the binding point (target). Possible values:

`gl.FRAMEBUFFER`

 Collection buffer data storage of color, alpha,
 depth and stencil buffers used to render an image.



 When using a WebGL 2 context,
 the following values are available additionally:


`gl.DRAW_FRAMEBUFFER`

 Equivalent to `gl.FRAMEBUFFER`.
 Used as a destination for drawing, rendering, clearing, and writing operations.


`gl.READ_FRAMEBUFFER`

Used as a source for reading operations.


### Return value

 A `GLenum` indicating the completeness status of the framebuffer or
 `0` if an error occurs. Possible enum return values:

* `gl.FRAMEBUFFER_COMPLETE`: The framebuffer is ready to display.
* `gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT`: The attachment types are
 mismatched or not all framebuffer attachment points are framebuffer attachment
 complete.
* `gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT`: There is no attachment.
* `gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS`: Height and width of the
 attachment are not the same.
* `gl.FRAMEBUFFER_UNSUPPORTED`: The format of the attachment is not
 supported or if depth and stencil attachments are not the same renderbuffer.
* When using a WebGL 2 context, the
 following values can be returned additionally:
    + `gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE`: The values of
     `gl.RENDERBUFFER_SAMPLES` are different among attached renderbuffers,
     or are non-zero if the attached images are a mix of renderbuffers and textures.
* When using the `OVR_multiview2` extension, the following value can be
 returned additionally:
    + `ext.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR`: If
     `baseViewIndex` is not the same for all framebuffer attachment points
     where the value of `FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE` is not
     `NONE`, the framebuffer is considered incomplete.
Examples
--------


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

// …

gl.checkFramebufferStatus(gl.FRAMEBUFFER);
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.6 |
| WebGL 2.0 Specification # 3.7.4 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.createFramebuffer()`
* `WebGLRenderingContext.deleteFramebuffer()`
* `WebGLRenderingContext.isFramebuffer()`
* Other buffers: `WebGLBuffer`, `WebGLRenderbuffer`
WebGLRenderingContext: frontFace() method
=========================================

 The **`WebGLRenderingContext.frontFace()`** method of the WebGL API specifies whether polygons are
 front- or back-facing by setting a winding orientation.

Syntax
------


```js
frontFace(mode)
```

### Parameters

`mode`

 A GLenum type winding orientation.
 The default value is `gl.CCW`. Possible values:


* `gl.CW`: Clock-wise winding.
* `gl.CCW`: Counter-clock-wise winding.

### Return value

None (`undefined`).

Examples
--------


```js
gl.frontFace(gl.CW);
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.3 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.cullFace()`
WebGLRenderingContext: enable() method
======================================

 The **`WebGLRenderingContext.enable()`** method of the WebGL API enables specific WebGL capabilities
 for this context.

Syntax
------


```js
enable(cap)
```

### Parameters

`cap`

 A `GLenum` specifying which WebGL capability to enable. Possible
 values:


| Constant | Description |
| --- | --- |
| `gl.BLEND` | Activates blending of the computed fragment color values. See `WebGLRenderingContext.blendFunc()`. |
| `gl.CULL_FACE` | Activates culling of polygons. See `WebGLRenderingContext.cullFace()`. |
| `gl.DEPTH_TEST` | Activates depth comparisons and updates to the depth buffer. See `WebGLRenderingContext.depthFunc()`. |
| `gl.DITHER` | Activates dithering of color components before they get written to the color buffer. |
| `gl.POLYGON_OFFSET_FILL` | Activates adding an offset to depth values of polygon's fragments. See `WebGLRenderingContext.polygonOffset()`. |
| `gl.SAMPLE_ALPHA_TO_COVERAGE` | Activates the computation of a temporary coverage value determined by the alpha value. |
| `gl.SAMPLE_COVERAGE` | Activates ANDing the fragment's coverage with the temporary coverage value. See `WebGLRenderingContext.sampleCoverage()`. |
| `gl.SCISSOR_TEST` | Activates the scissor test that discards fragments that are outside of the scissor rectangle. See `WebGLRenderingContext.scissor()`. |
| `gl.STENCIL_TEST` | Activates stencil testing and updates to the stencil buffer. See `WebGLRenderingContext.stencilFunc()`. |

 When using a WebGL 2 context, the
 following values are available additionally:


| Constant | Description |
| --- | --- |
| `gl.RASTERIZER_DISCARD` | Primitives are discarded immediately before the rasterization stage, but after the optional transform feedback stage. `gl.clear()` commands are ignored. |

### Return value

None (`undefined`).

Examples
--------


```js
gl.enable(gl.DITHER);
```


 To check if a capability is enabled, use the
 `WebGLRenderingContext.isEnabled()` method:


```js
gl.isEnabled(gl.DITHER);
// true
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.3 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.disable()`
* `WebGLRenderingContext.isEnabled()`
WebGLRenderingContext: lineWidth() method
=========================================

 The **`WebGLRenderingContext.lineWidth()`** method of the WebGL API sets the line width of rasterized
 lines.


**Warning:** The webgl spec, based on the OpenGL ES 2.0/3.0 specs points out that the minimum and
 maximum width for a line is implementation defined. The maximum minimum width is
 allowed to be 1.0. The minimum maximum width is also allowed to be 1.0. Because of
 these implementation defined limits it is not recommended to use line widths other
 than 1.0 since there is no guarantee any user's browser will display any other width.


 As of January 2017 most implementations of WebGL only support a minimum of 1 and a
 maximum of 1 as the technology they are based on has these same limits.


Syntax
------


```js
lineWidth(width)
```

### Parameters

`width`

A `GLfloat` specifying the width of rasterized lines. Default value: 1.

### Return value

None (`undefined`).

Examples
--------

Setting the line width:


```js
gl.lineWidth(5);
```


Getting the line width:


```js
gl.getParameter(gl.LINE\_WIDTH);
```


Getting the range of available widths. Returns a `Float32Array`.


```js
gl.getParameter(gl.ALIASED\_LINE\_WIDTH\_RANGE);
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.3 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext`
WebGLRenderingContext: getProgramInfoLog() method
=================================================

 The **WebGLRenderingContext.getProgramInfoLog** returns the information
 log for the specified `WebGLProgram` object. It contains errors that
 occurred during failed linking or validation of `WebGLProgram` objects.

Syntax
------


```js
getProgramInfoLog(program)
```

### Parameters

`program`

The `WebGLProgram` to query.

### Return value

 A string that contains diagnostic messages, warning messages, and
 other information about the last linking or validation operation. When a
 `WebGLProgram` object is initially created, its information log will be a
 string of length 0.

Examples
--------

### Checking program errors


```js
const program = gl.createProgram();

// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);

gl.linkProgram(program);

gl.getProgramInfoLog(program);
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.9 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.getShaderInfoLog()`
* `WebGLRenderingContext.getError()`
WebGLRenderingContext: isTexture() method
=========================================

 The **`WebGLRenderingContext.isTexture()`** method of the WebGL API returns `true` if the
 passed `WebGLTexture` is valid and `false` otherwise.

Syntax
------


```js
isTexture(texture)
```

### Parameters

`texture`

A `WebGLTexture` to check.

### Return value

A `GLboolean` indicating whether or not the texture is valid.

Examples
--------

### Checking a texture


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

gl.isTexture(texture);
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.8 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.bindTexture()`
* `WebGLRenderingContext.createTexture()`
* `WebGLRenderingContext.deleteTexture()`
* `WebGLRenderingContext.texImage2D()`
WebGLRenderingContext: scissor() method
=======================================

 The **`WebGLRenderingContext.scissor()`** method of the WebGL API sets a scissor box, which limits
 the drawing to a specified rectangle.

Syntax
------


```js
scissor(x, y, width, height)
```

### Parameters

`x`

 A `GLint` specifying the horizontal coordinate for the lower left
 corner of the box. Default value: 0.


`y`

 A `GLint` specifying the vertical coordinate for the lower left corner
 of the box. Default value: 0.


`width`

 A non-negative `GLsizei` specifying the width of the scissor box.
 Default value: width of the canvas.


`height`

 A non-negative `GLsizei` specifying the height of the scissor box.
 Default value: height of the canvas.


### Return value

None (`undefined`).

### Exceptions

 If either *width* or *height* is a negative value, a
 `gl.INVALID_VALUE` error is thrown.

Examples
--------

 When the scissor test is enabled, only pixels within the scissor box can be modified by
 drawing commands.


```js
// turn on scissor test
gl.enable(gl.SCISSOR\_TEST);

// set the scissor rectangle
gl.scissor(x, y, width, height);

// execute drawing commands in the scissor box (e.g. clear)

// turn off scissor test again
gl.disable(gl.SCISSOR\_TEST);
```


 To get the current scissor box dimensions, query the `SCISSOR_BOX` constant
 which returns an `Int32Array`.


```js
gl.scissor(0, 0, 200, 200);
gl.getParameter(gl.SCISSOR\_BOX);
// Int32Array[0, 0, 200, 200]
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.4 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.viewport()`
* `WebGLRenderingContext.enable()`
* `WebGLRenderingContext.disable()`
WebGLRenderingContext: isRenderbuffer() method
==============================================

 The **`WebGLRenderingContext.isRenderbuffer()`** method of the
 WebGL API returns `true` if the
 passed `WebGLRenderbuffer` is valid and `false` otherwise.

Syntax
------


```js
isRenderbuffer(renderbuffer)
```

### Parameters

`renderbuffer`

A `WebGLRenderbuffer` to check.

### Return value

A `GLboolean` indicating whether or not the renderbuffer is valid.

Examples
--------

### Checking a renderbuffer


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

gl.isRenderbuffer(renderbuffer);
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.7 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.bindRenderbuffer()`
* `WebGLRenderingContext.createRenderbuffer()`
* `WebGLRenderingContext.deleteRenderbuffer()`
* Other buffers: `WebGLBuffer`, `WebGLFramebuffer`
WebGLRenderingContext: deleteBuffer() method
============================================

 The **`WebGLRenderingContext.deleteBuffer()`** method of the WebGL API deletes a given
 `WebGLBuffer`. This method has no effect if the buffer has already been
 deleted. Normally you don't need to call this method yourself, when the buffer object is dereferenced it will be marked as free.

Syntax
------


```js
deleteBuffer(buffer)
```

### Parameters

`buffer`

A `WebGLBuffer` object to delete.

### Return value

None (`undefined`).

Examples
--------

### Deleting a buffer


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

// …

gl.deleteBuffer(buffer);
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.5 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.bindBuffer()`
* `WebGLRenderingContext.createBuffer()`
* `WebGLRenderingContext.isBuffer()`
* Other buffers: `WebGLFramebuffer`, `WebGLRenderbuffer`
WebGLRenderingContext: createFramebuffer() method
=================================================

 The **`WebGLRenderingContext.createFramebuffer()`** method of
 the WebGL API creates and initializes a
 `WebGLFramebuffer` object.

Syntax
------


```js
createFramebuffer()
```

### Parameters

None.

### Return value

A `WebGLFramebuffer` object.

Examples
--------

### Creating a frame buffer


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

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.6 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.bindFramebuffer()`
* `WebGLRenderingContext.deleteFramebuffer()`
* `WebGLRenderingContext.isFramebuffer()`
* Other buffers: `WebGLBuffer`, `WebGLRenderbuffer`
WebGLRenderingContext: stencilOpSeparate() method
=================================================

 The **`WebGLRenderingContext.stencilOpSeparate()`** method of
 the WebGL API sets the front and/or
 back-facing stencil test actions.

Syntax
------


```js
stencilOpSeparate(face, fail, zfail, zpass)
```

### Parameters

 The `fail`, `zfail` and `zpass` parameters accept all
 constants listed below.

`face`

 A `GLenum` specifying whether the front and/or back stencil state is
 updated. The possible values are:


* `gl.FRONT`
* `gl.BACK`
* `gl.FRONT_AND_BACK`

`fail`

 A `GLenum` specifying the function to use when the stencil test fails.
 The default value is `gl.KEEP`.


`zfail`

 A `GLenum` specifying the function to use when the stencil test passes,
 but the depth test fails. The default value is `gl.KEEP`.


`zpass`

 A `GLenum` specifying the function to use when both the stencil test
 and the depth test pass, or when the stencil test passes and there is no depth buffer
 or depth testing is disabled. The default value is `gl.KEEP`.


### Return value

None (`undefined`).

Constants
---------

`gl.KEEP`

Keeps the current value.

`gl.ZERO`

Sets the stencil buffer value to 0.

`gl.REPLACE`

 Sets the stencil buffer value to the reference value as specified by
 `WebGLRenderingContext.stencilFunc()`.


`gl.INCR`

 Increments the current stencil buffer value. Clamps to the maximum representable
 unsigned value.


`gl.INCR_WRAP`

 Increments the current stencil buffer value. Wraps stencil buffer value to zero when
 incrementing the maximum representable unsigned value.


`gl.DECR`

Decrements the current stencil buffer value. Clamps to 0.

`gl.DECR_WRAP`

 Decrements the current stencil buffer value. Wraps stencil buffer value to the
 maximum representable unsigned value when decrementing a stencil buffer value of 0.


`gl.INVERT`

Inverts the current stencil buffer value bitwise.

Examples
--------

 The stencil testing is disabled by default. To enable or disable stencil testing, use
 the `enable()` and
 `disable()` methods with the argument
 `gl.STENCIL_TEST`.


```js
gl.enable(gl.STENCIL\_TEST);
gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl.INVERT);
```


 To get the current information about stencil and depth pass or fail, query the
 following constants with `getParameter()`.


```js
gl.getParameter(gl.STENCIL\_FAIL);
gl.getParameter(gl.STENCIL\_PASS\_DEPTH\_PASS);
gl.getParameter(gl.STENCIL\_PASS\_DEPTH\_FAIL);
gl.getParameter(gl.STENCIL\_BACK\_FAIL);
gl.getParameter(gl.STENCIL\_BACK\_PASS\_DEPTH\_PASS);
gl.getParameter(gl.STENCIL\_BACK\_PASS\_DEPTH\_FAIL);
gl.getParameter(gl.STENCIL\_BITS);
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.3 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.stencilOp()`
* `WebGLRenderingContext.stencilFunc()`
* `WebGLRenderingContext.stencilFuncSeparate()`
* `WebGLRenderingContext.stencilMask()`
* `WebGLRenderingContext.stencilMaskSeparate()`
WebGLRenderingContext: stencilOp() method
=========================================

 The **`WebGLRenderingContext.stencilOp()`** method of the WebGL API sets both the front and back-facing
 stencil test actions.

Syntax
------


```js
stencilOp(fail, zfail, zpass)
```

### Parameters

All three parameters accept all constants listed below.

`fail`

 A `GLenum` specifying the function to use when the stencil test fails.
 The default value is `gl.KEEP`.


`zfail`

 A `GLenum` specifying the function to use when the stencil test passes,
 but the depth test fails. The default value is `gl.KEEP`.


`zpass`

 A `GLenum` specifying the function to use when both the stencil test
 and the depth test pass, or when the stencil test passes and there is no depth buffer
 or depth testing is disabled. The default value is `gl.KEEP`.


### Return value

None (`undefined`).

Constants
---------

`gl.KEEP`

Keeps the current value.

`gl.ZERO`

Sets the stencil buffer value to 0.

`gl.REPLACE`

 Sets the stencil buffer value to the reference value as specified by
 `WebGLRenderingContext.stencilFunc()`.


`gl.INCR`

 Increments the current stencil buffer value. Clamps to the maximum representable
 unsigned value.


`gl.INCR_WRAP`

 Increments the current stencil buffer value. Wraps stencil buffer value to zero when
 incrementing the maximum representable unsigned value.


`gl.DECR`

Decrements the current stencil buffer value. Clamps to 0.

`gl.DECR_WRAP`

 Decrements the current stencil buffer value. Wraps stencil buffer value to the
 maximum representable unsigned value when decrementing a stencil buffer value of 0.


`gl.INVERT`

Inverts the current stencil buffer value bitwise.

Examples
--------

 The stencil testing is disabled by default. To enable or disable stencil testing, use
 the `enable()` and
 `disable()` methods with the argument
 `gl.STENCIL_TEST`.


```js
gl.enable(gl.STENCIL\_TEST);
gl.stencilOp(gl.INCR, gl.DECR, gl.INVERT);
```


 To get the current information about stencil and depth pass or fail, query the
 following constants with `getParameter()`.


```js
gl.getParameter(gl.STENCIL\_FAIL);
gl.getParameter(gl.STENCIL\_PASS\_DEPTH\_PASS);
gl.getParameter(gl.STENCIL\_PASS\_DEPTH\_FAIL);
gl.getParameter(gl.STENCIL\_BACK\_FAIL);
gl.getParameter(gl.STENCIL\_BACK\_PASS\_DEPTH\_PASS);
gl.getParameter(gl.STENCIL\_BACK\_PASS\_DEPTH\_FAIL);
gl.getParameter(gl.STENCIL\_BITS);
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.3 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.stencilOpSeparate()`
* `WebGLRenderingContext.stencilFunc()`
* `WebGLRenderingContext.stencilFuncSeparate()`
* `WebGLRenderingContext.stencilMask()`
* `WebGLRenderingContext.stencilMaskSeparate()`
WebGLRenderingContext: drawingBufferWidth property
==================================================

 The read-only **`WebGLRenderingContext.drawingBufferWidth`**
 property represents the actual width of the current drawing buffer. It should match the
 `width` attribute of the `<canvas>` element associated with
 this context, but might differ if the implementation is not able to provide the
 requested width.

Value
-----

A number.

Examples
--------

Given this `<canvas>` element:


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


You can get the width of the drawing buffer with the following lines:


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

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # DOM-WebGLRenderingContext-drawingBufferWidth |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.drawingBufferHeight`
* `WebGLRenderingContext.viewport()`
WebGLRenderingContext: flush() method
=====================================

 The **`WebGLRenderingContext.flush()`** method of the WebGL API empties different buffer commands,
 causing all commands to be executed as quickly as possible.

Syntax
------


```js
flush()
```

### Parameters

None.

### Return value

None (`undefined`).

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.11 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.finish()`
WebGLRenderingContext: polygonOffset() method
=============================================

 The **`WebGLRenderingContext.polygonOffset()`** method of the
 WebGL API specifies the scale factors and
 units to calculate depth values.

 The offset is added before the depth test is performed and before the value is written
 into the depth buffer.

Syntax
------


```js
polygonOffset(factor, units)
```

### Parameters

`factor`

 A `GLfloat` which sets the scale factor for the variable depth offset
 for each polygon. The default value is 0.


`units`

 A `GLfloat` which sets the multiplier by which an
 implementation-specific value is multiplied with to create a constant depth offset.
 The default value is 0.


### Return value

None (`undefined`).

Examples
--------

 The polygon offset fill is disabled by default. To enable or disable polygon offset
 fill, use the `enable()` and
 `disable()` methods with the argument
 `gl.POLYGON_OFFSET_FILL`.


```js
gl.enable(gl.POLYGON\_OFFSET\_FILL);
gl.polygonOffset(2, 3);
```


 To check the current polygon offset factor or units, query the
 `POLYGON_OFFSET_FACTOR` and `POLYGON_OFFSET_UNITS` constants.


```js
gl.getParameter(gl.POLYGON\_OFFSET\_FACTOR); // 2
gl.getParameter(gl.POLYGON\_OFFSET\_UNITS); // 3
```

Specifications
--------------

| Specification |
| --- |
| WebGL Specification # 5.14.3 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.depthFunc()`