I've got a simple (I think) question about OpenGL texture arrays. I create my texture array with something like the following:
glTexImage3D(GL_TEXTURE_2D_ARRAY,
0,
formatGL,
width,
height,
slices,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
nullptr);
Note that I don't want to actually load any images into it yet. I'm just creating the structure that I'll be filling with data later on.
So my questions are:
How do I generate the mip chain for each "slice" of the texture array? I don't want to physically generate the mip, I just want to complete the texture by telling it about the mip. I can do this with 2D textures simply by calling the glTexImage2D function with the mip level, size and also passing in a nullptr. I can't see how to do this with the glTexImage3D function given there's no "slice" parameter. The OpenGL superbible example only loads a .bmp into the first mip level for each texture in the array. Is it correct to say that using glTexSubImage3D, passing in a nullptr, will create the mip level I want for a given texture in the array?
Documentation at khronos.org on glGenerateMipMap specifies GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP only. So is it correct to say I can't use this method for 2D texture arrays?
Here's what I do with 2D textures to create the mip chain:
size_t i = 0, mipSizeX = width, mipSizeY = height;
while(mipSizeX >= 1 || mipSizeY >= 1)
{
// Generate image for this mip level
glTexImage2D(GL_TEXTURE_2D,
i,
formatGL,
mipSizeX,
mipSizeY,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
nullptr);
// Go to the next mip size.
mipSizeX >>= 1;
mipSizeY >>= 1;
// and the next mipmap level.
i++;
}