Reference:activeTexture: Difference between revisions
Line 25: | Line 25: | ||
gl.activeTexture(gl.TEXTURE0 + textureUnit); | gl.activeTexture(gl.TEXTURE0 + textureUnit); | ||
... | ... | ||
gl.uniform1i(textureUnit); | gl.uniform1i(someSamplerLocation, textureUnit); | ||
</code> | </code> | ||
Revision as of 01:18, 5 August 2012
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(someSamplerLocation, textureUnit);
Errors
INVALID_ENUM is generated if texture is not between TEXTURE0 and TEXTURE0 + (MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1).
Associated Gets
getParameter with argument ACTIVE_TEXTURE or MAX_COMBINED_TEXTURE_IMAGE_UNITS