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);