Reference:activeTexture

From WebGL Public Wiki
Revision as of 01:12, 5 August 2012 by Gman (talk | contribs) (Notes)
Jump to navigation Jump to search

Name

activeTexture — select active texture unit

Specification

void activeTexture(GLenum texture);

Parameters

texture specifies which texture unit to make active. The number of texture units is implementation dependent, but must be at least eight. texture must be between TEXTURE0 and TEXTURE0 + (MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1). The initial value is TEXTURE0.

Description

activeTexture selects which texture unit subsequent texture state calls will affect. The number of texture units an implementation supports is implementation dependent, but must be at least 8.

Notes

A common mistake is that when setting an active texture unit activeTexture requires a value between TEXTURE0 and TEXTURE0 + (MAX_COMBINE_TEXTURE_IMAGE_UNITS - 1) where as when telling a program which texture unit to use uniform1i and/or uniform1iv require just 0 to (MAX_COMBINE_TEXTURE_IMAGE_UNITS - 1)

Example:

 var textureUnit = 3;
 gl.activeTexture(gl.TEXTURE0 + textureUnit);
 ...
 gl.uniform1i(textureUnit);

Errors

INVALID_ENUM is generated if texture is not between TEXTURE0 and TEXTURE0 + (MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1).

Associated Gets

glGet with argument GL_ACTIVE_TEXTURE, GL_MAX_TEXTURE_COORDS, or GL_MAX_COMBINED_TEXTURE_IMAGE_UNITSSee

Also

bindTexture