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

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

 The `WebGLRenderingContext.stencilMaskSeparate()` method can set front and
 back stencil writemasks to different values.

Syntax
------


```js
stencilMask(mask)
```

### Parameters

`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.stencilMask(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.stencilMaskSeparate()`
WebGLRenderingContext: clearDepth() method
==========================================

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

 This specifies what depth value to use when calling the
 `clear()` method. The value is clamped
 between 0 and 1.

Syntax
------


```js
clearDepth(depth)
```

### Parameters

`depth`

 A `GLclampf` specifying the depth value used when the depth buffer is
 cleared. Default value: 1.


### Return value

None (`undefined`).

Examples
--------


```js
gl.clearDepth(0.5);
```


 To get the current depth clear value, query the `DEPTH_CLEAR_VALUE`
 constant.


```js
gl.getParameter(gl.DEPTH\_CLEAR\_VALUE);
// 0.5
```

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

 The **`WebGLRenderingContext.bufferSubData()`** method of the
 WebGL API updates a subset of a buffer
 object's data store.

Syntax
------


```js
// WebGL1
bufferSubData(target, offset)
bufferSubData(target, offset, srcData)

// WebGL2
bufferSubData(target, dstByteOffset, srcOffset)
bufferSubData(target, dstByteOffset, srcData, srcOffset)
bufferSubData(target, dstByteOffset, srcData, srcOffset, length)
```

### Parameters

`target`

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

`gl.ARRAY_BUFFER`

 Buffer containing vertex attributes, such as
 vertex coordinates, texture coordinate data, or vertex color data.


`gl.ELEMENT_ARRAY_BUFFER`

Buffer used for element indices.


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


`gl.COPY_READ_BUFFER`

Buffer for copying from one buffer object to another.

`gl.COPY_WRITE_BUFFER`

Buffer for copying from one buffer object to another.

`gl.TRANSFORM_FEEDBACK_BUFFER`

Buffer for transform feedback operations.

`gl.UNIFORM_BUFFER`

Buffer used for storing uniform blocks.

`gl.PIXEL_PACK_BUFFER`

Buffer used for pixel transfer operations.

`gl.PIXEL_UNPACK_BUFFER`

Buffer used for pixel transfer operations.


`dstByteOffset`

 A `GLintptr` specifying an offset in bytes where the data replacement
 will start.


`srcData` Optional

 An `ArrayBuffer`, `SharedArrayBuffer`, a `DataView`, or a `TypedArray`
 that will be copied into the data store.


`srcOffset`

 A `GLuint` specifying the element index offset where to start reading
 the buffer.


`length` Optional

A `GLuint` defaulting to 0.

### Return value

None (`undefined`).

### Exceptions

* A `gl.INVALID_VALUE` error is thrown if the data would be written past
 the end of the buffer or if `data` is `null`.
* A `gl.INVALID_ENUM` error is thrown if `target` is not one of
 the allowed enums.
Examples
--------

### Using `bufferSubData`


```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY\_BUFFER, buffer);
gl.bufferData(gl.ARRAY\_BUFFER, 1024, gl.STATIC\_DRAW);
gl.bufferSubData(gl.ARRAY\_BUFFER, 512, data);
```

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.createBuffer()`
* `WebGLRenderingContext.bufferData()`
* Other buffers: `WebGLFramebuffer`, `WebGLRenderbuffer`
WebGLRenderingContext: getBufferParameter() method
==================================================

 The **`WebGLRenderingContext.getBufferParameter()`** method of
 the WebGL API returns information about the
 buffer.

Syntax
------


```js
getBufferParameter(target, pname)
```

### Parameters

`target`

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

`gl.ARRAY_BUFFER`

 Buffer containing vertex attributes, such as
 vertex coordinates, texture coordinate data, or vertex color data.


`gl.ELEMENT_ARRAY_BUFFER`

Buffer used for element indices.


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


`gl.COPY_READ_BUFFER`

Buffer for copying from one buffer object to another.

`gl.COPY_WRITE_BUFFER`

Buffer for copying from one buffer object to another.

`gl.TRANSFORM_FEEDBACK_BUFFER`

Buffer for transform feedback operations.

`gl.UNIFORM_BUFFER`

Buffer used for storing uniform blocks.

`gl.PIXEL_PACK_BUFFER`

Buffer used for pixel transfer operations.

`gl.PIXEL_UNPACK_BUFFER`

Buffer used for pixel transfer operations.


`pname`

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

`gl.BUFFER_SIZE`

 Returns a `GLint` indicating the size
 of the buffer in bytes.


`gl.BUFFER_USAGE`

 Returns a `GLenum` indicating the
 usage pattern of the buffer. One of the following:


* `gl.STATIC_DRAW`
* `gl.DYNAMIC_DRAW`
* `gl.STREAM_DRAW`

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


* `gl.STATIC_READ`
* `gl.DYNAMIC_READ`
* `gl.STREAM_READ`
* `gl.STATIC_COPY`
* `gl.DYNAMIC_COPY`
* `gl.STREAM_COPY`


### Return value

 Depends on the requested information (as specified with `pname`). Either a
 `GLint` or a `GLenum`.

Examples
--------


```js
gl.getBufferParameter(gl.ARRAY\_BUFFER, gl.BUFFER\_SIZE);
```

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

| Specification |
| --- |
| WebGL Specification # 5.14.5 |
| WebGL 2.0 Specification # 3.7.3 |

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

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

See also
--------

* `WebGLRenderingContext.bindBuffer()`
* `WebGLRenderingContext.createBuffer()`
* `WebGLRenderingContext.deleteBuffer()`
* `WebGLRenderingContext.bufferData()`
* Other buffers: `WebGLFramebuffer`, `WebGLRenderbuffer`
WebGLRenderingContext: sampleCoverage() method
==============================================

 The **`WebGLRenderingContext.sampleCoverage()`** method of the
 WebGL API specifies multi-sample coverage
 parameters for anti-aliasing effects.

Syntax
------


```js
sampleCoverage(value, invert)
```

### Parameters

`value`

 A `GLclampf` which sets a single floating-point coverage value clamped
 to the range [0,1]. The default value is 1.0.


`invert`

 A `GLboolean` which sets whether or not the coverage masks should be
 inverted. The default value is `false`.


### Return value

None (`undefined`).

Examples
--------

 Multi-sampling is disabled by default. To enable or disable multi-sampling, use the
 `enable()` and
 `disable()` methods with the argument
 `gl.SAMPLE_COVERAGE` and `gl.SAMPLE_ALPHA_TO_COVERAGE`.


```js
gl.enable(gl.SAMPLE\_COVERAGE);
gl.sampleCoverage(0.5, false);
```


 To check the sample coverage values, query the `SAMPLE_COVERAGE_VALUE` and
 `SAMPLE_COVERAGE_INVERT` constants.


```js
gl.getParameter(gl.SAMPLE\_COVERAGE\_VALUE); // 0.5
gl.getParameter(gl.SAMPLE\_COVERAGE\_INVERT); // false
```

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

* `HTMLCanvasElement.getContext()` – `antialias` parameter for
 the context.
WebGLRenderingContext: isBuffer() method
========================================

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

Syntax
------


```js
isBuffer(buffer)
```

### Parameters

`buffer`

A `WebGLBuffer` to check.

### Return value

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

Examples
--------

### Creating a buffer


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

gl.isBuffer(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.deleteBuffer()`
* Other buffers: `WebGLFramebuffer`, `WebGLRenderbuffer`
WebGLRenderingContext: detachShader() method
============================================

 The **WebGLRenderingContext.detachShader()** method of the WebGL API detaches a previously
 attached `WebGLShader` from a `WebGLProgram`.

Syntax
------


```js
detachShader(program, shader)
```

### Parameters

`program`

A `WebGLProgram`.

`shader`

A fragment or vertex `WebGLShader`.

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

* `WebGLProgram`
* `WebGLShader`
* `WebGLRenderingContext.attachShader()`
* `WebGLRenderingContext.compileShader()`
* `WebGLRenderingContext.createProgram()`
* `WebGLRenderingContext.createShader()`
* `WebGLRenderingContext.deleteProgram()`
* `WebGLRenderingContext.deleteShader()`
* `WebGLRenderingContext.detachShader()`
* `WebGLRenderingContext.getAttachedShaders()`
* `WebGLRenderingContext.getProgramParameter()`
* `WebGLRenderingContext.getProgramInfoLog()`
* `WebGLRenderingContext.getShaderParameter()`
* `WebGLRenderingContext.getShaderPrecisionFormat()`
* `WebGLRenderingContext.getShaderInfoLog()`
* `WebGLRenderingContext.getShaderSource()`
* `WebGLRenderingContext.isProgram()`
* `WebGLRenderingContext.isShader()`
* `WebGLRenderingContext.linkProgram()`
* `WebGLRenderingContext.shaderSource()`
* `WebGLRenderingContext.useProgram()`
* `WebGLRenderingContext.validateProgram()`
WebGLRenderingContext: drawArrays() method
==========================================

The **`WebGLRenderingContext.drawArrays()`** method of the WebGL API renders primitives from array data.

Syntax
------


```js
drawArrays(mode, first, count)
```

### Parameters

`mode`

 A `GLenum` specifying the type primitive to render. Possible values
 are:


* `gl.POINTS`: Draws a single dot.
* `gl.LINE_STRIP`: Draws a straight line to the next vertex.
* `gl.LINE_LOOP`: Draws a straight line to the next vertex, and
 connects the last vertex back to the first.
* `gl.LINES`: Draws a line between a pair of vertices.
* `gl.TRIANGLE_STRIP`
* `gl.TRIANGLE_FAN`
* `gl.TRIANGLES`: Draws a triangle for a group of three vertices.

`first`

A `GLint` specifying the starting index in the array of vector points.

`count`

A `GLsizei` specifying the number of indices to be rendered.

### Return value

None (`undefined`).

### Exceptions

* If `mode` is not one of the accepted values, a
 `gl.INVALID_ENUM` error is thrown.
* If `first` or `count` are negative, a
 `gl.INVALID_VALUE` error is thrown.
* if `gl.CURRENT_PROGRAM` is `null`, a
 `gl.INVALID_OPERATION` error is thrown.
Examples
--------


```js
gl.drawArrays(gl.POINTS, 0, 8);
```

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.drawElements()`
* `ext.drawArraysInstancedANGLE()`
* `ext.drawElementsInstancedANGLE()`
* `ext.vertexAttribDivisorANGLE()`
* `WebGL2RenderingContext.drawArraysInstanced()`
* `WebGL2RenderingContext.drawElementsInstanced()`
* `WebGL2RenderingContext.vertexAttribDivisor()`
* `WEBGL_multi_draw.multiDrawArraysWEBGL()`
WebGLRenderingContext: activeTexture() method
=============================================

 The **`WebGLRenderingContext.activeTexture()`** method of the
 WebGL API specifies which texture unit to
 make active.

Syntax
------


```js
activeTexture(texture)
```

### Parameters

`texture`

 The texture unit to make active. The value is a `gl.TEXTUREI`
 where *I* is within the range from 0 to
 `gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1`.


### Return value

None (`undefined`).

### Exceptions

 If *texture* is not one of `gl.TEXTUREI`, where *I*
 is within the range from 0 to `gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1`, a
 `gl.INVALID_ENUM` error is thrown.

Examples
--------

 The following call selects `gl.TEXTURE1` as the current texture. Subsequent
 calls that modify the texture state will affect this texture.


```js
gl.activeTexture(gl.TEXTURE1);
```


 The number of texture units is implementation dependent, you can get this number with
 the help of the `MAX_COMBINED_TEXTURE_IMAGE_UNITS` constant. It is, per
 specification, at least 8.


```js
gl.getParameter(gl.MAX\_COMBINED\_TEXTURE\_IMAGE\_UNITS);
```


To get the active texture, query the `ACTIVE_TEXTURE` constant.


```js
gl.activeTexture(gl.TEXTURE0);
gl.getParameter(gl.ACTIVE\_TEXTURE);
// returns "33984" (0x84C0, gl.TEXTURE0 enum value)
```

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.getParameter()`
WebGLRenderingContext: vertexAttrib[1234]f[v]() method
======================================================

 The **`WebGLRenderingContext.vertexAttrib[1234]f[v]()`**
 methods of the WebGL API specify constant
 values for generic vertex attributes.

Syntax
------


```js
vertexAttrib1f(index, v0)
vertexAttrib2f(index, v0, v1)
vertexAttrib3f(index, v0, v1, v2)
vertexAttrib4f(index, v0, v1, v2, v3)

vertexAttrib1fv(index, value)
vertexAttrib2fv(index, value)
vertexAttrib3fv(index, value)
vertexAttrib4fv(index, value)
```

### Parameters

`index`

 A `GLuint` specifying the position of the vertex attribute to be
 modified.


`v0, v1, v2, v3`

A floating point `Number` for the vertex attribute value.

`value`

A `Float32Array` for floating point vector vertex attribute values.

### Return value

None (`undefined`).

Description
-----------

 While vertex attributes are usually used to specify values which are different for each
 vertex (using `vertexAttribPointer`), it can be useful to specify a constant value. For example, if
 you have a shader which has a `color` vertex attribute, but you want to draw
 everything in a single color, you can use `vertexAttrib` to achieve that
 without creating a buffer filled with only one value or having to create a separate
 shader which uses a uniform for the color.

 This value will be used if a bound array buffer has not been enabled with
 `enableVertexAttribArray`.

 Attributes may be matrices, in which case columns of the matrix must be loaded into
 successive vertex attribute slots.

 The values set with `vertexAttrib` are context-global; that is, they aren't part of the shader state
 (like generic vertex attribute indexes to shader variable bindings) and aren't part of
 the vertex array object state (like enabled vertex attribute arrays). The only way to
 change the values is by calling this function again.

Examples
--------


```js
const a_foobar = gl.getAttribLocation(shaderProgram, "foobar");
//either set each component individually:
gl.vertexAttrib3f(a_foobar, 10.0, 5.0, 2.0);
//or provide a Float32Array:
const floatArray = new Float32Array([10.0, 5.0, 2.0]);
gl.vertexAttrib3fv(a_foobar, floatArray);
```



```js
// we want to load the following 3x3 matrix into attribute named "matrix3x3"
// 0 1 2
// 3 4 5
// 6 7 8
const matrix3x3Location = gl.getAttribLocation(shaderProgram, "matrix3x3");
gl.vertexAttrib3f(matrix3x3Location, 0, 3, 6);
gl.vertexAttrib3f(matrix3x3Location + 1, 1, 4, 7);
gl.vertexAttrib3f(matrix3x3Location + 2, 2, 5, 8);
```

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

 The **WebGLRenderingContext.compileShader()** method of the WebGL API compiles a GLSL shader into binary
 data so that it can be used by a `WebGLProgram`.

Syntax
------


```js
compileShader(shader)
```

### Parameters

`shader`

A fragment or vertex `WebGLShader`.

### Return value

None (`undefined`).

Examples
--------


```js
const shader = gl.createShader(gl.VERTEX\_SHADER);
gl.shaderSource(shader, shaderSource);
gl.compileShader(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
--------

* `WebGLProgram`
* `WebGLShader`
* `WebGLRenderingContext.attachShader()`
* `WebGLRenderingContext.createProgram()`
* `WebGLRenderingContext.createShader()`
* `WebGLRenderingContext.deleteProgram()`
* `WebGLRenderingContext.deleteShader()`
* `WebGLRenderingContext.detachShader()`
* `WebGLRenderingContext.getAttachedShaders()`
* `WebGLRenderingContext.getProgramParameter()`
* `WebGLRenderingContext.getProgramInfoLog()`
* `WebGLRenderingContext.getShaderParameter()`
* `WebGLRenderingContext.getShaderPrecisionFormat()`
* `WebGLRenderingContext.getShaderInfoLog()`
* `WebGLRenderingContext.getShaderSource()`
* `WebGLRenderingContext.isProgram()`
* `WebGLRenderingContext.isShader()`
* `WebGLRenderingContext.linkProgram()`
* `WebGLRenderingContext.shaderSource()`
* `WebGLRenderingContext.useProgram()`
* `WebGLRenderingContext.validateProgram()`
WebGLRenderingContext: isFramebuffer() method
=============================================

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

Syntax
------


```js
isFramebuffer(framebuffer)
```

### Parameters

`framebuffer`

A `WebGLFramebuffer` to check.

### Return value

A `GLboolean` indicating whether or not the frame buffer is valid.

Examples
--------

### Checking a frame buffer


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

gl.isFramebuffer(framebuffer);
```

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.createFramebuffer()`
* `WebGLRenderingContext.deleteFramebuffer()`
* Other buffers: `WebGLBuffer`, `WebGLRenderbuffer`
WebGLRenderingContext: isProgram() method
=========================================

 The **`WebGLRenderingContext.isProgram()`** method of the WebGL API returns `true` if the
 passed `WebGLProgram` is valid, `false` otherwise.

Syntax
------


```js
isProgram(program)
```

### Parameters

`program`

A `WebGLProgram` to check.

### Return value

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

Examples
--------

### Checking a program


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

// …

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

 The **`WebGLRenderingContext.getActiveAttrib()`** method of the
 WebGL API returns a
 `WebGLActiveInfo` object containing size, type, and name of a vertex
 attribute. It is generally used when querying unknown attributes either for debugging or
 generic library creation.

Syntax
------


```js
getActiveAttrib(program, index)
```

### Parameters

`program`

A `WebGLProgram` containing the vertex attribute.

`index`

 A `GLuint` specifying the index of the vertex attribute to get. This
 value is an index 0 to N - 1 as returned
 by `gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES)`.


### Return value

A `WebGLActiveInfo` object.

Examples
--------


```js
const numAttribs = gl.getProgramParameter(program, gl.ACTIVE\_ATTRIBUTES);
for (let i = 0; i < numAttribs; ++i) {
  const info = gl.getActiveAttrib(program, i);
  console.log("name:", info.name, "type:", info.type, "size:", info.size);
}
```

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

* `WebGLActiveInfo`