aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/webglrenderingcontext/blendequationseparate
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/blendequationseparate
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/blendequationseparate')
-rw-r--r--files/zh-cn/web/api/webglrenderingcontext/blendequationseparate/index.html126
1 files changed, 126 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/webglrenderingcontext/blendequationseparate/index.html b/files/zh-cn/web/api/webglrenderingcontext/blendequationseparate/index.html
new file mode 100644
index 0000000000..e274a77dde
--- /dev/null
+++ b/files/zh-cn/web/api/webglrenderingcontext/blendequationseparate/index.html
@@ -0,0 +1,126 @@
+---
+title: WebGLRenderingContext.blendEquationSeparate()
+slug: Web/API/WebGLRenderingContext/blendEquationSeparate
+translation_of: Web/API/WebGLRenderingContext/blendEquationSeparate
+---
+<div>{{APIRef("WebGL")}}</div>
+
+<p>The <strong><code>WebGLRenderingContext.blendEquationSeparate()</code></strong> method of the <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> is used to set the RGB blend equation and alpha blend equation separately.</p>
+
+<p>The blend equation determines how a new pixel is combined with a pixel already in the {{domxref("WebGLFramebuffer")}}.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox">void <var>gl</var>.blendEquationSeparate(<var>modeRGB, modeAlpha</var>);
+</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>modeRGB</code></dt>
+ <dd>A {{domxref("GLenum")}} specifying how the red, green and blue components of source and destination colors are combined. Must be either:
+ <ul>
+ <li><code>gl.FUNC_ADD</code>: source + destination (default value),</li>
+ <li><code>gl.FUNC_SUBTRACT</code>: source - destination,</li>
+ <li><code>gl.FUNC_REVERSE_SUBTRACT</code>: destination - source,</li>
+ <li>When using the {{domxref("EXT_blend_minmax")}} extension:
+ <ul>
+ <li><code>ext.MIN_EXT</code>: Minimum of source and destination,</li>
+ <li><code>ext.MAX_EXT</code>: Maximum of source and destination.</li>
+ </ul>
+ </li>
+ <li>When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:
+ <ul>
+ <li><code>gl.MIN</code>: Minimum of source and destination,</li>
+ <li><code>gl.MAX</code>: Maximum of source and destination.</li>
+ </ul>
+ </li>
+ </ul>
+ </dd>
+ <dt><code>modeAlpha</code></dt>
+ <dd>A {{domxref("GLenum")}} specifying how the alpha component (transparency) of source and destination colors are combined. Must be either:
+ <ul>
+ <li><code>gl.FUNC_ADD</code>: source + destination (default value),</li>
+ <li><code>gl.FUNC_SUBTRACT</code>: source - destination,</li>
+ <li><code>gl.FUNC_REVERSE_SUBTRACT</code>: destination - source,</li>
+ <li>When using the {{domxref("EXT_blend_minmax")}} extension:
+ <ul>
+ <li><code>ext.MIN_EXT</code>: Minimum of source and destination,</li>
+ <li><code>ext.MAX_EXT</code>: Maximum of source and destination.</li>
+ </ul>
+ </li>
+ <li>When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:
+ <ul>
+ <li><code>gl.MIN</code>: Minimum of source and destination,</li>
+ <li><code>gl.MAX</code>: Maximum of source and destination.</li>
+ </ul>
+ </li>
+ </ul>
+ </dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>None.</p>
+
+<h3 id="Exceptions">Exceptions</h3>
+
+<p>If <em>mode</em> is not one of the three possible values, a <code>gl.INVALID_ENUM</code> error is thrown.</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>To set the blend equations, use:</p>
+
+<pre class="brush: js">gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_SUBTRACT);
+</pre>
+
+<p>To get the current blend equations, query the <code>BLEND_EQUATION</code>, <code>BLEND_EQUATION_RGB</code> and <code>BLEND_EQUATION_ALPHA</code> constants which return <code>gl.FUNC_ADD</code>, <code>gl.FUNC_SUBTRACT</code>, <code>gl.FUNC_REVERSE_SUBTRACT</code>, or if the {{domxref("EXT_blend_minmax")}} is enabled: <code>ext.MIN_EXT</code> or <code>ext.MAX_EXT</code>.</p>
+
+<pre class="brush: js">gl.getParameter(gl.BLEND_EQUATION_RGB) === gl.FUNC_ADD;
+// true
+
+gl.getParameter(gl.BLEND_EQUATION_ALPHA) === gl.FUNC_ADD;
+// true
+</pre>
+
+<h2 id="Specifications">Specifications</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", "blendEquationSeparate")}}</td>
+ <td>{{Spec2('WebGL')}}</td>
+ <td>Initial definition for WebGL.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('OpenGL ES 2.0', "glBlendEquationSeparate.xml", "glBlendEquationSeparate")}}</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', "glBlendEquationSeparate.xhtml", "glBlendEquationSeparate")}}</td>
+ <td>{{Spec2('OpenGL ES 3.0')}}</td>
+ <td>Man page of the OpenGL ES 3.0 API.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</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.blendEquationSeparate")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("WebGLRenderingContext.blendEquation()")}}</li>
+ <li>{{domxref("WebGLRenderingContext.blendColor()")}}</li>
+ <li>{{domxref("WebGLRenderingContext.blendFunc()")}}</li>
+ <li>{{domxref("EXT_blend_minmax")}}</li>
+</ul>