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

 The **`WebGLRenderingContext.stencilMaskSeparate()`** method of
 the WebGL API controls enabling and
 disabling of front and/or back writing of individual bits in the stencil planes.

 The `WebGLRenderingContext.stencilMask()` method can set both, the front
 and back stencil writemasks to one value at the same time.

Syntax
------


```js
stencilMaskSeparate(face, mask)
```

### Parameters

`face`

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


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

`mask`

 A `GLuint` specifying a bit mask to enable or disable writing of
 individual bits in the stencil planes. By default, the mask is all 1.


### Return value

None (`undefined`).

Examples
--------


```js
gl.stencilMaskSeparate(gl.FRONT, 110101);
```


 To get the current stencil masks, query the `STENCIL_WRITEMASK`,
 `STENCIL_BACK_WRITEMASK`, or `STENCIL_BITS` constants.


```js
gl.getParameter(gl.STENCIL\_WRITEMASK);
// 110101
gl.getParameter(gl.STENCIL\_BACK\_WRITEMASK);
// 110101
gl.getParameter(gl.STENCIL\_BITS);
// 0
```

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.colorMask()`
* `WebGLRenderingContext.depthMask()`
* `WebGLRenderingContext.stencilMask()`
WebGLRenderingContext: bindRenderbuffer() method
================================================

 The **`WebGLRenderingContext.bindRenderbuffer()`** method of
 the WebGL API binds a given
 `WebGLRenderbuffer` to a target, which must be
 `gl.RENDERBUFFER`.

Syntax
------


```js
bindRenderbuffer(target, renderbuffer)
```

### Parameters

`target`

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

`gl.RENDERBUFFER`

 Buffer data storage for single images in a
 renderable internal format.



`renderbuffer`

A `WebGLRenderbuffer` object to bind.

### Return value

None (`undefined`).

### Exceptions

 A `gl.INVALID_ENUM` error is thrown if `target` is not
 `gl.RENDERBUFFER`.

Examples
--------

### Binding a renderbuffer


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

gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
```

### Getting current bindings

 To check the current renderbuffer binding, query the `RENDERBUFFER_BINDING`
 constant.


```js
gl.getParameter(gl.RENDERBUFFER\_BINDING);
```

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.createRenderbuffer()`
* `WebGLRenderingContext.deleteRenderbuffer()`
* `WebGLRenderingContext.isRenderbuffer()`
* Other buffers: `WebGLBuffer`, `WebGLFramebuffer`
WebGLRenderingContext: drawingBufferColorSpace property
=======================================================

The **`WebGLRenderingContext.drawingBufferColorSpace`** property specifies the color space of the WebGL drawing buffer. Along with the default (`srgb`), the `display-p3` color space can be used.

See `WebGLRenderingContext.unpackColorSpace` for specifying the color space for textures.

Value
-----

This property can have the following values:

* `"srgb"` selects the sRGB color space. This is the default value.
* `"display-p3"` selects the display-p3 color space.

If an invalid value is specified, then the value of `drawingBufferColorSpace` will remain unchanged.

Examples
--------

### Setting the drawing buffer color space to draw a Display P3 red


```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.drawingBufferColorSpace = "display-p3";
gl.clearColor(1, 0, 0, 1);
gl.clear(glP3.COLOR\_BUFFER\_BIT);
```

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

| Specification |
| --- |
| WebGL Specification # DOM-WebGLRenderingContext-drawingBufferColorSpace |

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

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

See also
--------

* `WebGLRenderingContext.unpackColorSpace`
WebGLRenderingContext: getShaderParameter() method
==================================================

 The **`WebGLRenderingContext.getShaderParameter()`** method of
 the WebGL API returns information about the
 given shader.

Syntax
------


```js
getShaderParameter(shader, pname)
```

### Parameters

`shader`

A `WebGLShader` to get parameter information from.

`pname`

A `GLenum` specifying the information to query. Possible values:

`gl.DELETE_STATUS`

 Returns a `GLboolean` indicating
 whether or not the shader is flagged for deletion.


`gl.COMPILE_STATUS`

 Returns a `GLboolean` indicating
 whether or not the last shader compilation was successful.


`gl.SHADER_TYPE`

 Returns a `GLenum` indicating whether
 the shader is a vertex shader (`gl.VERTEX_SHADER`) or fragment shader
 (`gl.FRAGMENT_SHADER`) object.



### Return value

Returns the requested shader information (as specified with `pname`).

Examples
--------


```js
gl.getShaderParameter(shader, gl.SHADER\_TYPE);
```

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.getProgramParameter()`
WebGLRenderingContext: deleteProgram() method
=============================================

 The **`WebGLRenderingContext.deleteProgram()`** method of the
 WebGL API deletes a given
 `WebGLProgram` object. This method has no effect if the program has already
 been deleted.

Syntax
------


```js
deleteProgram(program)
```

### Parameters

`program`

A `WebGLProgram` object to delete.

### Return value

None (`undefined`).

Examples
--------

### Deleting a program


```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const program = gl.createProgram();

// …

gl.deleteProgram(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.createProgram()`
* `WebGLRenderingContext.isProgram()`
* `WebGLRenderingContext.linkProgram()`
* `WebGLRenderingContext.useProgram()`
* `WebGLRenderingContext.validateProgram()`
* `WebGLRenderingContext.getProgramParameter()`
* `WebGLRenderingContext.getProgramInfoLog()`
WebGLRenderingContext: renderbufferStorage() method
===================================================

 The **`WebGLRenderingContext.renderbufferStorage()`** method of
 the WebGL API creates and initializes a
 renderbuffer object's data store.

Syntax
------


```js
renderbufferStorage(target, internalFormat, width, height)
```

### Parameters

`target`

A `GLenum` specifying the target renderbuffer object. Possible values:

`gl.RENDERBUFFER`

Buffer data storage for single images in a renderable internal format.


`internalFormat`

 A `GLenum` specifying the internal format of the renderbuffer. Possible
 values:


* `gl.RGBA4`: 4 red bits, 4 green bits, 4 blue bits 4 alpha bits.
* `gl.RGB565`: 5 red bits, 6 green bits, 5 blue bits.
* `gl.RGB5_A1`: 5 red bits, 5 green bits, 5 blue bits, 1 alpha bit.
* `gl.DEPTH_COMPONENT16`: 16 depth bits.
* `gl.STENCIL_INDEX8`: 8 stencil bits.
* `gl.DEPTH_STENCIL`

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


* `gl.R8`
* `gl.R8UI`
* `gl.R8I`
* `gl.R16UI`
* `gl.R16I`
* `gl.R32UI`
* `gl.R32I`
* `gl.RG8`
* `gl.RG8UI`
* `gl.RG8I`
* `gl.RG16UI`
* `gl.RG16I`
* `gl.RG32UI`
* `gl.RG32I`
* `gl.RGB8`
* `gl.RGBA8`
* `gl.SRGB8_ALPHA8` (also available as an extension for WebGL 1, see below)
* `gl.RGB10_A2`
* `gl.RGBA8UI`
* `gl.RGBA8I`
* `gl.RGB10_A2UI`
* `gl.RGBA16UI`
* `gl.RGBA16I`
* `gl.RGBA32I`
* `gl.RGBA32UI`
* `gl.DEPTH_COMPONENT24`
* `gl.DEPTH_COMPONENT32F`
* `gl.DEPTH24_STENCIL8`
* `gl.DEPTH32F_STENCIL8`

When using the `WEBGL_color_buffer_float` extension:

* `ext.RGBA32F_EXT`: RGBA 32-bit floating-point type.
* `ext.RGB32F_EXT`: RGB 32-bit floating-point type.

When using the `EXT_sRGB` extension:

* `ext.SRGB8_ALPHA8_EXT`: 8-bit sRGB and alpha.

 When using a WebGL 2 context and
 the `EXT_color_buffer_float` extension:


* `gl.R16F`
* `gl.RG16F`
* `gl.RGBA16F`
* `gl.R32F`
* `gl.RG32F`
* `gl.RGBA32F`
* `gl.R11F_G11F_B10F`

`width`

A `GLsizei` specifying the width of the renderbuffer in pixels.

`height`

A `GLsizei` specifying the height of the renderbuffer in pixels.

### Return value

None (`undefined`).

Examples
--------


```js
gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 256, 256);
```

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

| Specification |
| --- |
| WebGL Specification # 5.14.7 |
| WebGL 2.0 Specification # 3.7.5 |

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()`
* `WebGLRenderingContext.getRenderbufferParameter()`
* `WEBGL_color_buffer_float`
* `EXT_sRGB`
* `EXT_color_buffer_float`
* `EXT_texture_norm16`
WebGLRenderingContext: deleteShader() method
============================================

 The **`WebGLRenderingContext.deleteShader()`** method of the WebGL API marks a given
 `WebGLShader` object for deletion. It will then be deleted whenever the
 shader is no longer in use. This method has no effect if the shader has already been
 deleted, and the `WebGLShader` is automatically marked for deletion when it
 is destroyed by the garbage collector.

Syntax
------


```js
deleteShader(shader)
```

### Parameters

`shader`

A `WebGLShader` object to delete.

### Return value

None (`undefined`).

Examples
--------

### Deleting a shader


```js
gl.deleteShader(shader);
```

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.createShader()`
* `WebGLRenderingContext.isShader()`
* `WebGLRenderingContext.getAttachedShaders()`
WebGLRenderingContext: createProgram() method
=============================================

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

Syntax
------


```js
createProgram()
```

### Parameters

None.

### Return value

 A `WebGLProgram` object that is a combination of two compiled
 `WebGLShader`s consisting of a vertex shader and a fragment shader (both
 written in GLSL). These are then linked into a usable program.

Examples
--------

### Creating a WebGL program


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

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

gl.linkProgram(program);

if (!gl.getProgramParameter(program, gl.LINK\_STATUS)) {
  const info = gl.getProgramInfoLog(program);
  throw `Could not compile WebGL program. \n\n${info}`;
}
```


 See `WebGLShader` for information on creating the
 `vertexShader` and `fragmentShader` in the above example.

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.deleteProgram()`
* `WebGLRenderingContext.isProgram()`
* `WebGLRenderingContext.linkProgram()`
* `WebGLRenderingContext.useProgram()`
* `WebGLRenderingContext.validateProgram()`
* `WebGLRenderingContext.getProgramParameter()`
* `WebGLRenderingContext.getProgramInfoLog()`
WebGLRenderingContext: getVertexAttribOffset() method
=====================================================

 The **`WebGLRenderingContext.getVertexAttribOffset()`** method
 of the WebGL API returns the address of a
 specified vertex attribute.

Syntax
------


```js
getVertexAttribOffset(index, pname)
```

### Parameters

`index`

A `GLuint` specifying the index of the vertex attribute.

`pname`

A `GLenum` which must be `gl.VERTEX_ATTRIB_ARRAY_POINTER`.

### Return value

A `GLintptr` indicating the address of the vertex attribute.

Examples
--------


```js
gl.getVertexAttribOffset(i, gl.VERTEX\_ATTRIB\_ARRAY\_POINTER);
```

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

| Specification |
| --- |
| WebGL Specification # 5.14.10 |

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

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

See also
--------

* `WebGLRenderingContext.vertexAttribPointer()`
WebGLRenderingContext: createRenderbuffer() method
==================================================

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

Syntax
------


```js
createRenderbuffer()
```

### Parameters

None.

### Return value

 A `WebGLRenderbuffer` object that stores data such an image, or can be
 source or target of an rendering operation.

Examples
--------

### Creating a render buffer


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

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.deleteRenderbuffer()`
* `WebGLRenderingContext.isRenderbuffer()`
* Other buffers: `WebGLBuffer`, `WebGLFramebuffer`
WebGLRenderingContext: validateProgram() method
===============================================

 The **`WebGLRenderingContext.validateProgram()`** method of the
 WebGL API validates a
 `WebGLProgram`. It checks if it is successfully linked and if it can be
 used in the current WebGL state.

Syntax
------


```js
validateProgram(program)
```

### Parameters

`program`

A `WebGLProgram` to validate.

### Return value

None (`undefined`).

Examples
--------


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

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

gl.linkProgram(program);
gl.validateProgram(program);

if (!gl.getProgramParameter(program, gl.LINK\_STATUS)) {
  const info = gl.getProgramInfoLog(program);
  throw `Could not compile WebGL program. \n\n${info}`;
}

gl.useProgram(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.createProgram()`
* `WebGLRenderingContext.deleteProgram()`
* `WebGLRenderingContext.isProgram()`
* `WebGLRenderingContext.linkProgram()`
* `WebGLRenderingContext.useProgram()`
* `WebGLRenderingContext.getProgramParameter()`
* `WebGLRenderingContext.getProgramInfoLog()`
WebGLRenderingContext: disableVertexAttribArray() method
========================================================

 The **`WebGLRenderingContext.disableVertexAttribArray()`**
 method of the WebGL API turns the generic
 vertex attribute array off at a given index position.

Syntax
------


```js
disableVertexAttribArray(index)
```

### Parameters

`index`

A `GLuint` specifying the index of the vertex attribute to disable.

### Return value

None (`undefined`).

Examples
--------


```js
gl.disableVertexAttribArray(0);
```

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

| Specification |
| --- |
| WebGL Specification # 5.14.10 |

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

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

See also
--------

* `WebGLRenderingContext.enableVertexAttribArray()`
WebGLRenderingContext: hint() method
====================================

 The **`WebGLRenderingContext.hint()`** method of the WebGL API specifies hints for certain
 behaviors. The interpretation of these hints depend on the implementation.

Syntax
------


```js
hint(target, mode)
```

### Parameters

`target`

Sets which behavior to be controlled. Possible values:

`gl.GENERATE_MIPMAP_HINT`

 Quality of filtering when generating
 mipmap images with `WebGLRenderingContext.generateMipmap()`.


When using the `OES_standard_derivatives` extension:

`ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES`

 Accuracy of the
 derivative calculation for the GLSL built-in functions: `dFdx`,
 `dFdy`, and `fwidth`.



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


`gl.FRAGMENT_SHADER_DERIVATIVE_HINT`

Same as `ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES`


`mode`

 Sets the behavior. The default value is `gl.DONT_CARE`. The possible
 values are:


* `gl.FASTEST`: The most efficient behavior should be used.
* `gl.NICEST`: The most correct or the highest quality option should be
 used.
* `gl.DONT_CARE`: There is no preference for this behavior.

### Return value

None (`undefined`).

Examples
--------

 The following example hints that the quality of filtering when generating mipmap images
 should be most efficient instead of the best quality.


```js
gl.hint(gl.GENERATE\_MIPMAP\_HINT, gl.FASTEST);
```

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.generateMipmap()`
* `OES_standard_derivatives`
WebGLRenderingContext: clearStencil() method
============================================

 The **`WebGLRenderingContext.clearStencil()`** method of the WebGL API specifies the clear value for the
 stencil buffer.

 This specifies what stencil value to use when calling the
 `clear()` method.

Syntax
------


```js
clearStencil(s)
```

### Parameters

`s`

 A `GLint` specifying the index used when the stencil buffer is cleared.
 Default value: 0.


### Return value

None (`undefined`).

Examples
--------


```js
gl.clearStencil(1);
```


 To get the current stencil clear value, query the `STENCIL_CLEAR_VALUE`
 constant.


```js
gl.getParameter(gl.STENCIL\_CLEAR\_VALUE);
// 1
```

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.clear()`
* `WebGLRenderingContext.clearColor()`
* `WebGLRenderingContext.clearDepth()`
WebGLRenderingContext: blendEquation() method
=============================================

 The **`WebGLRenderingContext.blendEquation()`** method of the
 WebGL API is used to set both the RGB blend
 equation and alpha blend equation to a single equation.

 The blend equation determines how a new pixel is combined with a pixel already in the
 `WebGLFramebuffer`.

Syntax
------


```js
blendEquation(mode)
```

### Parameters

`mode`

 A `GLenum` specifying how source and destination colors are combined.
 Must be either:


* `gl.FUNC_ADD`: source + destination (default value)
* `gl.FUNC_SUBTRACT`: source - destination
* `gl.FUNC_REVERSE_SUBTRACT`: destination - source

When using the `EXT_blend_minmax` extension:

* `ext.MIN_EXT`: Minimum of source and destination
* `ext.MAX_EXT`: Maximum of source and destination

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


* `gl.MIN`: Minimum of source and destination
* `gl.MAX`: Maximum of source and destination

### Exception

 If *mode* is not one of the three possible values, a
 `gl.INVALID_ENUM` error is thrown.

### Return value

None (`undefined`).

Examples
--------

To set the blend equation, use:


```js
gl.blendEquation(gl.FUNC\_ADD);
gl.blendEquation(gl.FUNC\_SUBTRACT);
gl.blendEquation(gl.FUNC\_REVERSE\_SUBTRACT);
```


 To get the blend equations, query the `BLEND_EQUATION`,
 `BLEND_EQUATION_RGB` and `BLEND_EQUATION_ALPHA` constants which
 return `gl.FUNC_ADD`, `gl.FUNC_SUBTRACT`,
 `gl.FUNC_REVERSE_SUBTRACT`, or if the `EXT_blend_minmax` is
 enabled: `ext.MIN_EXT` or `ext.MAX_EXT`.


```js
gl.getParameter(gl.BLEND\_EQUATION\_RGB) === gl.FUNC\_ADD;
// true

gl.getParameter(gl.BLEND\_EQUATION\_ALPHA) === gl.FUNC\_ADD;
// 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.blendColor()`
* `WebGLRenderingContext.blendFunc()`
* `EXT_blend_minmax`
WebGLRenderingContext: blendColor() method
==========================================

 The **`WebGLRenderingContext.blendColor()`** method of the WebGL API is used to set the source and
 destination blending factors.

Syntax
------


```js
blendColor(red, green, blue, alpha)
```

### Parameters

`red`

A `GLclampf` for the red component in the range of 0 to 1. Default value is 0.

`green`

A `GLclampf` for the green component in the range of 0 to 1. Default value is 0.

`blue`

A `GLclampf` for the blue component in the range of 0 to 1. Default value is 0.

`alpha`

 A `GLclampf` for the alpha component (transparency) in the range of 0.
 to 1. Default value is 0.


### Return value

None (`undefined`).

Examples
--------

To set the blend color, use:


```js
gl.blendColor(0, 0.5, 1, 1);
```


 To get the blend color, query the `BLEND_COLOR` constant which returns a
 `Float32Array`.


```js
gl.getParameter(gl.BLEND\_COLOR);
// Float32Array[0, 0.5, 1, 1]
```

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.blendEquation()`
* `WebGLRenderingContext.blendFunc()`