Array Textures are textures that are a sequence of 1D or 2D textures of the same size. Array textures are similar to 3D Textures in that they have an effective "depth" component. However, filtering never takes place between the separate textures in the array.
Array texture are not usable from the fixed function pipeline. To use them, you have to use an assembly or GLSL shader. Therefore it is invalid to call:
and will result in the OpenGL error flag being set to GL_INVALID_ENUM.
To bind and initialize a texture object as an array texture in a typical case, you should write:
GLuint texture = 0;
//Set this to the preferred texture width.
GLuint width = 2;
//Set this to the preferred texture height.
GLuint height = 2;
//Set this to the preferred texture slice count.
GLuint sliceCount = 2;
//Read you texels here. In the current example, we have 2*2*2*4=32 texels.
GLfloat texels =
//Texels for first image.
//Texels for second image.
To declare a GLSL sampler for texture arrays:
uniform sampler2DArray textureName;
to read from the sampler, write:
vec4 color = texture2DArray(textureName,texCoord.xyz);
where texCoord.xy contains s,t for the 2D image texture coordinates and texCoord.z contains the array index of the texture. s and t are in the range of [0..1] (floating point), array index is in the range of [0..number of texture array slices-1] (floating point rounded to nearest integer).
|This article is a stub. You can help the OpenGL Wiki by expanding it.|