There is something I fail to understand completely about texture update in OpenGL.Let's say I create OpenGL texture with mipmaps like this:
///.. tex gen and bind here .... ///
glTexStorage2D(GL_TEXTURE_2D,numMipMapLevels,GL_RGBA8,imageInfo.Width,imageInfo.Height);
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,Width,Height,GL_BGRA,GL_UNSIGNED_BYTE,data);
glGenerateMipmap(GL_TEXTURE_2D);
Now the first question: Does it mean ,when I want to update this texture including all the mipmap level ,do I have to loop over each level and call glTexSubImage2D with appropriate mipmap dimension and image bytes?If the answer is YES , then I have:
second question: How do I retrieve each mipmap dimension and data to pass into the texture?
Alternatively , can I just do the update :
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,Width,Height,GL_BGRA,GL_UNSIGNED_BYTE,data);
And re-generate mipmaps immediately afterwards?
glGenerateMipmap(GL_TEXTURE_2D);