glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, image[0].width(), image[0].height(), image.size(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
for (int i = 0; i < image.size(); ++i)
{
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, i, image[i].width(), image[i].height(), 1, GL_RGBA, GL_UNSIGNED_BYTE, image[i].bits());
}
- I don’t understand why the texture is white.
How are you accessing the texture? Array textures can only be used via shaders, not the fixed-function pipeline.