Hello. I render a cube, and load its textures from png files. When I load the first png texture, it is rendered good, but for the rest of them I get a GL_INVALID_VALUE error in glTexSubImage3D line.
//Now generate the OpenGL texture object
GLuint texture;
GLsizei mipLevelCount = 8;
glGenTextures(1, &texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
int width, height;
for (int j = 0; j < texture_names.size(); ++j)
{
// here a png[j] is read to * array.
....
// update width and height, always 256x256
....
if (j == 0)
{
glTexStorage3D(GL_TEXTURE_2D_ARRAY, mipLevelCount, GL_RGBA8, width, height, texture_names.size());
}
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, j, 0, 0, 0, width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)image_data);
// release resources
...
}
.....