diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/webglrenderingcontext/enable/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/webglrenderingcontext/enable/index.html')
-rw-r--r-- | files/zh-cn/web/api/webglrenderingcontext/enable/index.html | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/webglrenderingcontext/enable/index.html b/files/zh-cn/web/api/webglrenderingcontext/enable/index.html new file mode 100644 index 0000000000..19fe6655ff --- /dev/null +++ b/files/zh-cn/web/api/webglrenderingcontext/enable/index.html @@ -0,0 +1,156 @@ +--- +title: WebGLRenderingContext.enable() +slug: Web/API/WebGLRenderingContext/enable +tags: + - WebGLRenderingContext.enable +translation_of: Web/API/WebGLRenderingContext/enable +--- +<div>{{APIRef("WebGL")}}</div> + +<p><a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> 中的<strong><code>WebGLRenderingContext.enable()</code></strong> 方法,用于对该上下文开启某种特性。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">void <var>gl</var>.enable(<var>cap</var>);参数</pre> + +<dl> + <dt><code>cap</code></dt> + <dd>让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>激活片元的颜色融合计算. 参见 {{domxref("WebGLRenderingContext.blendFunc()")}}.</td> + </tr> + <tr> + <td><code>gl.CULL_FACE</code></td> + <td>激活多边形正反面剔除. 参见{{domxref("WebGLRenderingContext.cullFace()")}}.</td> + </tr> + <tr> + <td><code>gl.DEPTH_TEST</code></td> + <td> + <p>激活深度比较,并且更新深度缓冲区。参见{{domxref("WebGLRenderingContext.depthFunc()")}}.</p> + </td> + </tr> + <tr> + <td><code>gl.DITHER</code></td> + <td> + <p> </p> + + <p>激活在写入颜色缓冲区之前,抖动颜色成分。</p> + </td> + </tr> + <tr> + <td><code>gl.POLYGON_OFFSET_FILL</code></td> + <td> + <p>激活添加多边形片段的深度值偏移。参见{{domxref("WebGLRenderingContext.polygonOffset()")}}.</p> + </td> + </tr> + <tr> + <td><code>gl.SAMPLE_ALPHA_TO_COVERAGE</code></td> + <td> + <p>激活通过alpha值决定的临时覆盖值计算。(抗锯齿)</p> + </td> + </tr> + <tr> + <td><code>gl.SAMPLE_COVERAGE</code></td> + <td> + <p>激活使用临时覆盖值,位和运算片段的覆盖值。参见 {{domxref("WebGLRenderingContext.sampleCoverage()")}}.</p> + </td> + </tr> + <tr> + <td><code>gl.SCISSOR_TEST</code></td> + <td> + <p>激活剪裁测试,即丢弃在剪裁矩形范围外的片段。{{domxref("WebGLRenderingContext.scissor()")}}.</p> + </td> + </tr> + <tr> + <td><code>gl.STENCIL_TEST</code></td> + <td> + <p>激活模板测试并且更新模板缓冲区。参见{{domxref("WebGLRenderingContext.stencilFunc()")}}.</p> + </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> + <p>图元光栅化阶段之前,但在任意的transform反馈之后,就立刻被丢弃。<code>gl.clear()命令被忽略。</code></p> + </td> + </tr> + </tbody> + </table> + </dd> +</dl> + +<h3 id="返回值">返回值</h3> + +<p>None.</p> + +<h2 id="样例">样例</h2> + +<pre class="brush: js">gl.enable(gl.DITHER); +</pre> + +<p>如果要检测可用性,可以使用 {{domxref("WebGLRenderingContext.isEnabled()")}} 方法:</p> + +<pre class="brush: js">gl.isEnabled(gl.DITHER); +// true +</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", "enable")}}</td> + <td>{{Spec2('WebGL')}}</td> + <td>Initial definition for WebGL.</td> + </tr> + <tr> + <td>{{SpecName('OpenGL ES 2.0', "glEnable.xml", "glEnable")}}</td> + <td>{{Spec2('OpenGL ES 2.0')}}</td> + <td>Man page of the OpenGL ES 2.0 API.</td> + </tr> + <tr> + <td>{{SpecName('OpenGL ES 3.0', "glEnable.xhtml", "glEnable")}}</td> + <td>{{Spec2('OpenGL ES 3.0')}}</td> + <td>Man page of the OpenGL ES 3.0 API.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("api.WebGLRenderingContext.enable")}}</p> + +<h2 id="另见">另见</h2> + +<ul> + <li>{{domxref("WebGLRenderingContext.disable()")}}</li> + <li>{{domxref("WebGLRenderingContext.isEnabled()")}}</li> +</ul> |