Reference:activeTexture: Difference between revisions
Created page with "==Name== activeTexture — select active texture unit ==Specification== <code> void activeTexture(GLenum texture); </code> ==Parameters== '''texture''' specifies which tex..." |
|||
Line 18: | Line 18: | ||
==Notes== | ==Notes== | ||
A common mistake is that when setting an active texture unit <tt>activeTexture</tt> requires a value between TEXTURE0 and TEXTURE0 + (MAX_COMBINE_TEXTURE_IMAGE_UNITS - 1) where as when telling a program which texture unit to use [[Reference:uniform|uniform1i]] and/or [[Reference:uniform|uniform1iv]] require just 0 to (MAX_COMBINE_TEXTURE_IMAGE_UNITS - 1) | |||
Example: | |||
<code> | |||
var textureUnit = 3; | |||
gl.activeTexture(gl.TEXTURE0 + textureUnit); | |||
... | |||
gl.uniform1i(textureUnit); | |||
</code> | |||
==Errors== | ==Errors== |
Revision as of 01:12, 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(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