I'm trying to load multiple textures (from 8x8 *.bmp images) into multiple FBOs, by the following snippet:
glTexImage3D(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGB8I_EXT, TEXTURE_WIDTH, TEXTURE_HEIGHT, TEXTURE_NUM, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
for( int i = 0; i < TEXTURE_NUM; i++ )
{
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBO_ID[i]);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, TEXTURE_WIDTH, TEXTURE_HEIGHT);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO_ID[i]);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, TexArray_ID, 0, i);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, RBO_ID[i]);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
checkGLErrors("begin check");
for ( int i = 0; i < TEXTURE_NUM; i++ )
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO_ID[i]);
char fileName[32];
sprintf(fileName, "./img/%02d.bmp", i);
unsigned char* imgData;
imgData = loadBMP(fileName);
if (imgData)
printf("imgData %s is successfully loaded\n",fileName);
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, i, 8, 8, 1, GL_RGB, GL_UNSIGNED_BYTE, imgData);
checkGLErrors("end check");
free(imgData);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, NULL);
}
However, I cannot get these textures attached using glTexSubImage3D function. The CheckGLErrors() indicates that the error is in the following line, stating "Invalid Value" error.
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, i, 8, 8, 1, GL_RGB, GL_UNSIGNED_BYTE, imgData);
After reading the manual , i think the error is associated with the following statement:
GL_INVALID_VALUE is generated if xoffset < - b , xoffset + width > w - b , yoffset < - b , or yoffset + height > h - b , or zoffset < - b , or zoffset + depth > d - b , where w is the GL_TEXTURE_WIDTH, h is the GL_TEXTURE_HEIGHT, d is the GL_TEXTURE_DEPTH and b is the border width of the texture image being modified. Note that w, h, and d include twice the border width.
Which left me no clue on how to get these textures work. Any Ideas? Thanks in advance.