1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
---
title: WebGLRenderingContext.isEnabled()
slug: Web/API/WebGLRenderingContext/isEnabled
translation_of: Web/API/WebGLRenderingContext/isEnabled
---
<div>{{APIRef("WebGL")}}</div>
<p><strong><code>WebGLRenderingContext.isEnabled()</code></strong> 是 <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> 方法之一,用来检测给定的 WebGL 功能项在当前上下文是否可用。</p>
<p>默认的,除了 <code>gl.DITHER</code>,所有的功能项都是未启用的。</p>
<h2 id="句法">句法</h2>
<pre class="syntaxbox">void <var>gl</var>.isEnabled(<var>cap</var>);
</pre>
<h3 id="参数">参数</h3>
<dl>
<dt><code>cap</code></dt>
<dd>{{domxref("GLenum")}} 指定待检测的 WebGL 功能项。可能的值有:</dd>
<dd>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Constant</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.BLEND</code></td>
<td>Blending of the computed fragment color values. See {{domxref("WebGLRenderingContext.blendFunc()")}}.</td>
</tr>
<tr>
<td><code>gl.CULL_FACE</code></td>
<td>Culling of polygons. See {{domxref("WebGLRenderingContext.cullFace()")}}.</td>
</tr>
<tr>
<td><code>gl.DEPTH_TEST</code></td>
<td>Depth comparisons and updates to the depth buffer. See {{domxref("WebGLRenderingContext.depthFunc()")}}.</td>
</tr>
<tr>
<td><code>gl.DITHER</code></td>
<td>Dithering of color components before they get written to the color buffer.</td>
</tr>
<tr>
<td><code>gl.POLYGON_OFFSET_FILL</code></td>
<td>Adding an offset to depth values of polygon's fragments. See {{domxref("WebGLRenderingContext.polygonOffset()")}}.</td>
</tr>
<tr>
<td><code>gl.SAMPLE_ALPHA_TO_COVERAGE</code></td>
<td>Computation of a temporary coverage value determined by the alpha value.</td>
</tr>
<tr>
<td><code>gl.SAMPLE_COVERAGE</code></td>
<td>ANDing the fragment's coverage with the temporary coverage value. See {{domxref("WebGLRenderingContext.sampleCoverage()")}}.</td>
</tr>
<tr>
<td><code>gl.SCISSOR_TEST</code></td>
<td>Scissor test that discards fragments that are outside of the scissor rectangle. See {{domxref("WebGLRenderingContext.scissor()")}}.</td>
</tr>
<tr>
<td><code>gl.STENCIL_TEST</code></td>
<td>Stencil testing and updates to the stencil buffer. See {{domxref("WebGLRenderingContext.stencilFunc()")}}.</td>
</tr>
</tbody>
</table>
当使用 {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}} 的时候,下列附加的值也是可选用的。
<table class="standard-table">
<thead>
<tr>
<th scope="col">Constant</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.RASTERIZER_DISCARD</code></td>
<td>Primitives are discarded immediately before the rasterization stage, but after the optional transform feedback stage. <code>gl.clear()</code> commands are ignored.</td>
</tr>
</tbody>
</table>
</dd>
</dl>
<h3 id="返回值">返回值</h3>
<p>{{domxref("GLboolean")}} 指示能力项 <em>cap </em>可用 (<code>true</code>),不可用 (<code>false</code>)。</p>
<h2 id="示例">示例</h2>
<pre class="brush: js">gl.isEnabled(gl.STENCIL_TEST);
// false
</pre>
<p>启用或停用给定的能力项,使用 {{domxref("WebGLRenderingContext.enable()")}} 方法和 {{domxref("WebGLRenderingContext.disable()")}} 方法:</p>
<pre class="brush: js">gl.enable(gl.STENCIL_TEST);
gl.disable(gl.STENCIL_TEST);
</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('WebGL', "#5.14.3", "isEnabled")}}</td>
<td>{{Spec2('WebGL')}}</td>
<td>Initial definition for WebGL.</td>
</tr>
<tr>
<td>{{SpecName('OpenGL ES 2.0', "glIsEnabled.xml", "glIsEnabled")}}</td>
<td>{{Spec2('OpenGL ES 2.0')}}</td>
<td>Man page of the (similar) OpenGL ES 2.0 API.</td>
</tr>
<tr>
<td>{{SpecName('WebGL2', "#3.7.2", "isEnabled")}}</td>
<td>{{Spec2('WebGL2')}}</td>
<td>Updated definition for WebGL 2.</td>
</tr>
<tr>
<td>{{SpecName('OpenGL ES 3.0', "glIsEnabled.xhtml", "glIsEnabled")}}</td>
<td>{{Spec2('OpenGL ES 3.0')}}</td>
<td>Man page of the (similar) OpenGL ES 3.0 API.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<div>{{CompatibilityTable}}</div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatChrome("9")}}</td>
<td>{{CompatGeckoDesktop("2.0")}}</td>
<td>{{CompatIE("11")}}</td>
<td>{{CompatOpera("12")}}</td>
<td>{{CompatSafari("5.1")}}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatUnknown}}</td>
<td>25</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>12</td>
<td>8.1</td>
</tr>
</tbody>
</table>
</div>
<h2 id="另见">另见</h2>
<ul>
<li>{{domxref("WebGLRenderingContext.enable()")}}</li>
<li>{{domxref("WebGLRenderingContext.disable()")}}</li>
</ul>
|