title: Generating mip levels for a 2D texture array
body: <p>I've got a simple (I think) question about OpenGL texture arrays. I create my texture array with something like the following:</p>
  
  <pre><code>glTexImage3D(   GL_TEXTURE_2D_ARRAY,
          0,
          formatGL,
          width,
          height,
          slices,
          0,
          GL_RGBA, 
          GL_UNSIGNED_BYTE, 
          nullptr);
  </code></pre>
  
  <p>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.</p>
  
  <p>So my questions are:</p>
  
  <ol>
  <li><p>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?</p></li>
  <li><p>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?</p></li>
  </ol>
  
  <p>Here's what I do with 2D textures to create the mip chain:</p>
  
  <pre><code>    size_t i = 0, mipSizeX = width, mipSizeY = height;
  
      while(mipSizeX &gt;= 1 || mipSizeY &gt;= 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 &gt;&gt;= 1;
          mipSizeY &gt;&gt;= 1;
  
          // and the next mipmap level.
  
          i++;
      }
  </code></pre>