Browse Source

opengl: fix creating compressed array textures with > 1 layer.

Fixes #1817.
slime 3 years ago
parent
commit
8495cefd3b
1 changed files with 4 additions and 6 deletions
  1. 4 6
      src/modules/graphics/opengl/Image.cpp

+ 4 - 6
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++)