Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. WebGLRenderingContext
  4. activeTexture()

WebGLRenderingContext: activeTexture() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

Note: This feature is available inWeb Workers.

TheWebGLRenderingContext.activeTexture() method of theWebGL API specifies which texture unit tomake active.

Syntax

js
activeTexture(texture)

Parameters

texture

The texture unit to make active. The value is agl.TEXTUREIwhereI is within the range from 0 togl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1.

Return value

None (undefined).

Exceptions

Iftexture is not one ofgl.TEXTUREI, whereIis within the range from 0 togl.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, agl.INVALID_ENUM error is thrown.

Examples

The following call selectsgl.TEXTURE1 as the current texture. Subsequentcalls that modify the texture state will affect this texture.

js
gl.activeTexture(gl.TEXTURE1);

The number of texture units is implementation dependent, you can get this number withthe help of theMAX_COMBINED_TEXTURE_IMAGE_UNITS constant. It is, perspecification, at least 8.

js
gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);

To get the active texture, query theACTIVE_TEXTURE constant.

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

Specifications

Specification
WebGL Specification
# 5.14.3

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp