Search code examples
opengltextures

glTexSubImage3D not updating texture


I am trying to update only a part of one texture in a large texture array with 16 4096*4096 textures using glTexSubImage3D. However, I can't get it to work. The call does not throw any errors. (While setting width to more than 4096 does).

glTexSubImage3D(  GL_TEXTURE_2D_ARRAY, // target
                                    0, // level
                                    0, // x offset
                                    0, // y offset
                                    0, // z offset
                          TEXTURE_DIM, // width
                          TEXTURE_DIM, // height
                                    0, // depth
                              GL_RGBA, // format
                     GL_UNSIGNED_BYTE, // type
                          textures[1]); // zeroed memory

This is strange because when I replace this call with glTexImage3D, the texture is updated:

glTexImage3D(GL_TEXTURE_2D_ARRAY, // target
                               0, // level
                        GL_RGBA8, // Internal format
                     TEXTURE_DIM, // width
                     TEXTURE_DIM, // height
                               1,  // the number of layers 
                               0,  // 0 required
                         GL_RGBA,  // format
                GL_UNSIGNED_BYTE,  // type
                     textures[1]); // zeroed memory

Am I missing some additional steps that glTexSubImage3D needs? What might be the problem? Thanks for any pointers


Solution

  • The depth parameter has to be to be 1 in your case. Note, the size of the region which is updated is widht * height * depth. If depth is 0, then nothing is changed at all.