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.
In this article
Syntax
activeTexture(texture)Parameters
textureThe texture unit to make active. The value is a
gl.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.
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.
gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);To get the active texture, query theACTIVE_TEXTURE constant.
gl.activeTexture(gl.TEXTURE0);gl.getParameter(gl.ACTIVE_TEXTURE);// returns "33984" (0x84C0, gl.TEXTURE0 enum value)Specifications
| Specification |
|---|
| WebGL Specification> # 5.14.3> |