diff --git a/src/modules/graphics/opengl/Image.cpp b/src/modules/graphics/opengl/Image.cpp index 511d5d45a..f42ffa12d 100644 --- a/src/modules/graphics/opengl/Image.cpp +++ b/src/modules/graphics/opengl/Image.cpp @@ -116,16 +116,14 @@ void Image::loadData() { if (isCompressed() && (texType == TEXTURE_2D_ARRAY || texType == TEXTURE_VOLUME)) { + int mipslices = data.getSliceCount(mip); size_t mipsize = 0; - if (texType == TEXTURE_2D_ARRAY || texType == TEXTURE_VOLUME) - { - for (int slice = 0; slice < data.getSliceCount(mip); slice++) - mipsize += data.get(slice, mip)->getSize(); - } + for (int slice = 0; slice < mipslices; slice++) + mipsize += data.get(slice, mip)->getSize(); GLenum gltarget = OpenGL::getGLTextureType(texType); - glCompressedTexImage3D(gltarget, mip, fmt.internalformat, w, h, d, 0, mipsize, nullptr); + glCompressedTexImage3D(gltarget, mip, fmt.internalformat, w, h, mipslices, 0, mipsize, nullptr); } for (int slice = 0; slice < slicecount; slice++)