WebGLRenderingContext.activeTexture() - Web APIs 编辑

The WebGLRenderingContext.activeTexture() method of the WebGL API specifies which texture unit to make active.

Syntax

void gl.activeTexture(texture);

Parameters

texture
The texture unit to make active. The value is a gl.TEXTUREI where I is within the range from 0 to gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1.

Return value

None.

Exceptions

If texture is not one of gl.TEXTUREI, where I is within the range from 0 to gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, a gl.INVALID_ENUM error is thrown.

Examples

The following call selects gl.TEXTURE1 as the current texture. Subsequent calls that modify the texture state will affect this texture.

gl.activeTexture(gl.TEXTURE1);

The number of texture units is implementation dependent, you can get this number with the help of the MAX_COMBINED_TEXTURE_IMAGE_UNITS constant. It is, per specification, at least 8.

gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);

To get the active texture, query the ACTIVE_TEXTURE constant.

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

Specifications

SpecificationStatusComment
WebGL 1.0
The definition of 'activeTexture' in that specification.
RecommendationInitial definition.
OpenGL ES 2.0
The definition of 'glActiveTexture' in that specification.
StandardMan page of the OpenGL API.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:140 次

字数:3655

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文