From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../webglrenderingcontext/activetexture/index.html | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 files/zh-cn/web/api/webglrenderingcontext/activetexture/index.html (limited to 'files/zh-cn/web/api/webglrenderingcontext/activetexture') 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 +--- +
{{APIRef("WebGL")}}
+ +

WebGLRenderingContext.activeTexture() 是 WebGL API 方法之一,用来激活指定的纹理单元。

+ +

句法

+ +
void gl.activeTexture(texture);
+
+ +

参数

+ +
+
texture
+
需要激活的纹理单元。其值是 gl.TEXTUREI ,其中的 I 在 0 到 gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1 范围内。
+
+ +

返回值

+ +

无返回值。

+ +

异常

+ +

如果 texture 不是 gl.TEXTUREI( I 在 0 到 gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1 范围内),一个 gl.INVALID_ENUM 错误将被抛出。

+ +

示例

+ +

接下来调用 gl.TEXTURE1 作为当前纹理,随后对纹理状态的更改将会影响到这个纹理。

+ +
gl.activeTexture(gl.TEXTURE1);
+
+ +

纹理单元的数量视实现而定, 你可以通过访问常量 MAX_COMBINED_TEXTURE_IMAGE_UNITS 来获取这个值。按照规范来说,最少是 8 个。

+ +
gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+
+ +

想要获取激活的纹理,可以查询常量 ACTIVE_TEXTURE

+ +
gl.activeTexture(gl.TEXTURE0);
+gl.getParameter(gl.ACTIVE_TEXTURE);
+// returns "33984" (0x84C0, gl.TEXUTURE0 enum value)
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebGL', "#5.14.3", "activeTexture")}}{{Spec2('WebGL')}}Initial definition.
{{SpecName('OpenGL ES 2.0', "glActiveTexture.xml", "glActiveTexture")}}{{Spec2('OpenGL ES 2.0')}}Man page of the OpenGL API.
+ +

浏览器兼容性

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("9")}}{{CompatGeckoDesktop("2.0")}}{{CompatIE("11")}}{{CompatOpera("12")}}{{CompatSafari("5.1")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}25{{CompatVersionUnknown}}{{CompatUnknown}}128.1
+
+ +

另见

+ + -- cgit v1.2.3-54-g00ecf