WebGLRenderingContext: isEnabled() method

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 in Web Workers.

Phương thức WebGLRenderingContext.isEnabled() của WebGL API kiểm tra xem một khả năng WebGL cụ thể có được kích hoạt hay không cho bối cảnh này.

Theo mặc định, tất cả các khả năng ngoại trừ gl.DITHER đều bị tắt.

Cú pháp

js
isEnabled(cap)

Thông số

cap

Một GLenum chỉ định khả năng WebGL nào cần kiểm tra. Các giá trị có thể:

Constant Description
gl.BLEND Blending of the computed fragment color values. See WebGLRenderingContext.blendFunc().
gl.CULL_FACE Culling of polygons. See WebGLRenderingContext.cullFace().
gl.DEPTH_TEST Depth comparisons and updates to the depth buffer. See WebGLRenderingContext.depthFunc().
gl.DITHER Dithering of color components before they get written to the color buffer.
gl.POLYGON_OFFSET_FILL Adding an offset to depth values of polygon's fragments. See WebGLRenderingContext.polygonOffset().
gl.SAMPLE_ALPHA_TO_COVERAGE Computation of a temporary coverage value determined by the alpha value.
gl.SAMPLE_COVERAGE ANDing the fragment's coverage with the temporary coverage value. See WebGLRenderingContext.sampleCoverage().
gl.SCISSOR_TEST Scissor test that discards fragments that are outside of the scissor rectangle. See WebGLRenderingContext.scissor().
gl.STENCIL_TEST Stencil testing and updates to the stencil buffer. See WebGLRenderingContext.stencilFunc().

Khi sử dụng WebGL 2 context, các giá trị sau đây có sẵn bổ sung:

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

Giá trị trả về

Một GLboolean cho biết khả năng cap có được bật hay không (true), hay không (false).

Ví dụ

js
gl.isEnabled(gl.STENCIL_TEST);
// false

Để kích hoạt hoặc hủy kích hoạt một khả năng cụ thể, hãy sử dụng các phương thức WebGLRenderingContext.enable()WebGLRenderingContext.disable():

js
gl.enable(gl.STENCIL_TEST);
gl.disable(gl.STENCIL_TEST);

Thông số kỹ thuật

Specification
WebGL Specification
# 5.14.3
WebGL 2.0 Specification
# 3.7.2

Khả năng tương thích của trình duyệt

Xem thêm