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
isEnabled(cap)
Thông số
cap-
Một
GLenumchỉ định khả năng WebGL nào cần kiểm tra. Các giá trị có thể:Constant Description gl.BLENDBlending of the computed fragment color values. See WebGLRenderingContext.blendFunc().gl.CULL_FACECulling of polygons. See WebGLRenderingContext.cullFace().gl.DEPTH_TESTDepth comparisons and updates to the depth buffer. See WebGLRenderingContext.depthFunc().gl.DITHERDithering of color components before they get written to the color buffer. gl.POLYGON_OFFSET_FILLAdding an offset to depth values of polygon's fragments. See WebGLRenderingContext.polygonOffset().gl.SAMPLE_ALPHA_TO_COVERAGEComputation of a temporary coverage value determined by the alpha value. gl.SAMPLE_COVERAGEANDing the fragment's coverage with the temporary coverage value. See WebGLRenderingContext.sampleCoverage().gl.SCISSOR_TESTScissor test that discards fragments that are outside of the scissor rectangle. See WebGLRenderingContext.scissor().gl.STENCIL_TESTStencil 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ụ
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() và WebGLRenderingContext.disable():
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> |