When I try this code, it doesn’t work. For some reason only mip level 0 is present and all other mip levels are black.
GLuint texture = 0;
glGenTextures(1, &texture);
glTextureStorage2DEXT(texture, GL_TEXTURE_2D, 10, GL_RGBA8, 512, 512);
glTextureSubImage2DEXT(texture, GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);
glGenerateTextureMipmapEXT(texture, GL_TEXTURE_2D);
If I try this code however, all mip levels are present and accounted for.
GLuint texture = 0;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexStorage2D(GL_TEXTURE_2D, 10, GL_RGBA8, 512, 512);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);
glGenerateMipmap(GL_TEXTURE_2D);
and strangely enough this works as well.
GLuint texture = 0;
glGenTextures(1, &texture);
glTextureImage2DEXT(texture, GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_buffer);
glGenerateTextureMipmapEXT(texture, GL_TEXTURE_2D);
This is using OpenGL 4.3 core profile on a AMD HD 5850 using the latest drivers.