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/activetexture | |
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/activetexture')
-rw-r--r-- | files/zh-cn/web/api/webglrenderingcontext/activetexture/index.html | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/webglrenderingcontext/activetexture/index.html b/files/zh-cn/web/api/webglrenderingcontext/activetexture/index.html new file mode 100644 index 0000000000..6e5f43f563 --- /dev/null +++ b/files/zh-cn/web/api/webglrenderingcontext/activetexture/index.html @@ -0,0 +1,127 @@ +--- +title: WebGLRenderingContext.activeTexture() +slug: Web/API/WebGLRenderingContext/activeTexture +translation_of: Web/API/WebGLRenderingContext/activeTexture +--- +<div>{{APIRef("WebGL")}}</div> + +<p><strong><code>WebGLRenderingContext.activeTexture() </code></strong>是 <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> 方法之一,用来激活指定的纹理单元。</p> + +<h2 id="句法">句法</h2> + +<pre class="syntaxbox"><var><em>void gl</em>.activeTexture</var><var>(texture);</var> +</pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><code>texture</code></dt> + <dd>需要激活的纹理单元。其值是 <code>gl.TEXTURE<em>I</em></code> ,其中的 <em>I</em> 在 0 到 <code>gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1 </code>范围内。</dd> +</dl> + +<h3 id="返回值">返回值</h3> + +<p>无返回值。</p> + +<h3 id="异常">异常</h3> + +<p>如果 <em>texture </em>不是 <code>gl.TEXTURE<em>I(</em></code> <em>I </em>在 0 到 <code>gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1 </code>范围内),一个 <code>gl.INVALID_ENUM</code> 错误将被抛出。</p> + +<h2 id="示例">示例</h2> + +<p>接下来调用 <code>gl.TEXTURE1</code> 作为当前纹理,随后对纹理状态的更改将会影响到这个纹理。</p> + +<pre class="brush: js">gl.activeTexture(gl.TEXTURE1); +</pre> + +<p>纹理单元的数量视实现而定, 你可以通过访问常量 <code>MAX_COMBINED_TEXTURE_IMAGE_UNITS</code> 来获取这个值。按照规范来说,最少是 8 个。</p> + +<pre class="brush: js">gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS); +</pre> + +<p>想要获取激活的纹理,可以查询常量 <code>ACTIVE_TEXTURE</code><code>。</code></p> + +<pre class="brush: js">gl.activeTexture(gl.TEXTURE0); +gl.getParameter(gl.ACTIVE_TEXTURE); +// returns "33984" (0x84C0, gl.TEXUTURE0 enum 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.3", "activeTexture")}}</td> + <td>{{Spec2('WebGL')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('OpenGL ES 2.0', "glActiveTexture.xml", "glActiveTexture")}}</td> + <td>{{Spec2('OpenGL ES 2.0')}}</td> + <td>Man page of the OpenGL 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.getParameter()")}}</li> +</ul> |