aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/webglrenderingcontext/clear/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/webglrenderingcontext/clear/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/webglrenderingcontext/clear/index.html')
-rw-r--r--files/zh-cn/web/api/webglrenderingcontext/clear/index.html89
1 files changed, 89 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/webglrenderingcontext/clear/index.html b/files/zh-cn/web/api/webglrenderingcontext/clear/index.html
new file mode 100644
index 0000000000..ac8f044933
--- /dev/null
+++ b/files/zh-cn/web/api/webglrenderingcontext/clear/index.html
@@ -0,0 +1,89 @@
+---
+title: WebGLRenderingContext.clear()
+slug: Web/API/WebGLRenderingContext/clear
+translation_of: Web/API/WebGLRenderingContext/clear
+---
+<div>{{APIRef("WebGL")}}</div>
+
+<p><a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> 的 <strong><code>WebGLRenderingContext.clear()</code></strong> 方法使用预设值来清空缓冲。</p>
+
+<p>预设值可以使用 {{domxref("WebGLRenderingContext.clearColor", "clearColor()")}} 、 {{domxref("WebGLRenderingContext.clearDepth", "clearDepth()")}} 或 {{domxref("WebGLRenderingContext.clearStencil", "clearStencil()")}} 设置。</p>
+
+<p>裁剪、抖动处理和缓冲写入遮罩会影响 <code>clear()</code> 方法。</p>
+
+<h2 id="句法">句法</h2>
+
+<pre class="syntaxbox">void <var>gl</var>.clear(<var>mask</var>);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>mask</code></dt>
+ <dd>一个用于指定需要清除的缓冲区的 {{domxref("GLbitfield")}} 。可能的值有:
+ <ul>
+ <li><code>gl.COLOR_BUFFER_BIT   //颜色缓冲区</code></li>
+ <li><code>gl.DEPTH_BUFFER_BIT   //深度缓冲区</code></li>
+ <li><code>gl.STENCIL_BUFFER_BIT  //模板缓冲区</code></li>
+ </ul>
+ </dd>
+</dl>
+
+<h3 id="错误抛出">错误抛出</h3>
+
+<p>如果mask不是以上列出的值,会抛出 <code>gl.INVALID_ENUM</code> 错误。</p>
+
+<h3 id="返回值">返回值</h3>
+
+<p>无</p>
+
+<h2 id="示例">示例</h2>
+
+<p><code>clear()</code> 方法可接受复合值,</p>
+
+<pre class="brush: js">gl.clear(gl.DEPTH_BUFFER_BIT);
+gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT);
+</pre>
+
+<p>要获得当前的清除值,传入 <code>COLOR_CLEAR_VALUE</code>,、<code>DEPTH_CLEAR_VALUE或</code><code>STENCIL_CLEAR_VALUE</code> 常量。</p>
+
+<pre class="brush: js">gl.getParameter(gl.COLOR_CLEAR_VALUE);
+gl.getParameter(gl.DEPTH_CLEAR_VALUE);
+gl.getParameter(gl.STENCIL_CLEAR_VALUE);
+</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.11", "clear")}}</td>
+ <td>{{Spec2('WebGL')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('OpenGL ES 2.0', "glClear.xml", "glClear")}}</td>
+ <td>{{Spec2('OpenGL ES 2.0')}}</td>
+ <td>Man page of the OpenGL 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", "WebGLRenderingContext.clear")}}</p>
+
+<h2 id="相关内容">相关内容</h2>
+
+<ul>
+ <li>{{domxref("WebGLRenderingContext.clearColor()")}}</li>
+ <li>{{domxref("WebGLRenderingContext.clearDepth()")}}</li>
+ <li>{{domxref("WebGLRenderingContext.clearStencil()")}}</li>
+</ul>