Using GL_TEXTURE_2D_ARRAY to store multiple shadowmaps.

Hello everyone,
I am trying to figure out how use a texture array 2D to handle multiple shadowmaps, each one attached to its own FBO.

 
    //texturearray2d used to store 2 textures with only one image in each of them (is this correct? I took it from the wiki) 
    mipLevelCount = 1;
    layerCount = 2;
    glGenTextures(1,&texture);
    glBindTexture(GL_TEXTURE_2D_ARRAY,texture);
    glTexStorage3D(GL_TEXTURE_2D_ARRAY, mipLevelCount, ->_DONT_KNOW_<-, myshadowWidth, myshadowHeight, layerCount);
    glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
    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);

My first issue is: which internal format should I specify up there?

Also, is this the correct way to create a complete fbo for a shadowmap in the previously created array?


    
    int fbo;
    glGenFramebuffers(1, &fbo);
    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowMapArray, 0, index_of_the_ith_shadowmap);
    glDrawBuffer(GL_NONE);
    glReadBuffer(GL_NONE);
    GLenum c = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if ( c == GL_FRAMEBUFFER_COMPLETE )
    {
        cout << "FBO ShadowMap " << index_of_the_ith_shadowmap << " is complete";
    }
    else
    {
       cout <<"Error in FBO ShadowMap "  << index;
     }
   glBindFramebuffer(FramebufferTarget.Framebuffer, 0);

My first issue is: which internal format should I specify up there?

… the same internal format you would have specified if you used a regular 2D texture.

Array textures are not some magical form of texture. They’re just a different use of texture; they can store the same stuff.

Thanks for your answer Alfonse. I hope you’ll understand my inexperience, this is still the beginners’ section am I right? I am confused by the fact that the ArrayTexture’s tutorial says one should use glTexStorage3D, while shadowmap’s tutorials I am following (like this or this) adopt a straight glTexImage2D. At the moment I’m trying to do the same with glTexImage3D, is my reasoning flawed? (Sorry, I am a beginner)

Edit1: I initialized the texture array with


    glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT, myshadowWidth, myshadowHeight, layerCount, 0, GL_DEPTH_COMPONENT, GL_FLOAT, null);
[\CODE]
and the code is used for the fbo's setup printed out "FBO ShadowMap _right_number_ is complete". So I guess I'm good to go now :) or am I falling in a silly pitfall?

Edit2: It looks like my shadowmaps work! I colored a stanford bunny on account of which shadowmap test was resulting positive for each point and the colours were just right.