Fixed (I think?) linear size calculation for S3TC/DXTC data. default tip
authorRyan C. Gordon <icculus@icculus.org>
Tue, 10 May 2011 14:23:00 -0400
changeset 11 7e2785b01d10
parent 10 1e5f3d130b53
Fixed (I think?) linear size calculation for S3TC/DXTC data.
mojodds.c
--- a/mojodds.c	Tue May 10 14:22:31 2011 -0400
+++ b/mojodds.c	Tue May 10 14:23:00 2011 -0400
@@ -174,15 +174,18 @@
         {
             case FOURCC_DXT1:
                 *_glfmt = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
-                calcSize = ((width ? ((width + 3) / 4) : 1) * 8) * height;
+                calcSize = ((width ? ((width + 3) / 4) : 1) * 8) *
+                           (height ? ((height + 3) / 4) : 1);
                 break;
             case FOURCC_DXT3:
                 *_glfmt = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
-                calcSize = ((width ? ((width + 3) / 4) : 1) * 16) * height;
+                calcSize = ((width ? ((width + 3) / 4) : 1) * 16) *
+                           (height ? ((height + 3) / 4) : 1);
                 break;
             case FOURCC_DXT5:
                 *_glfmt = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
-                calcSize = ((width ? ((width + 3) / 4) : 1) * 16) * height;
+                calcSize = ((width ? ((width + 3) / 4) : 1) * 16) *
+                           (height ? ((height + 3) / 4) : 1);
                 break;
 
             // !!! FIXME: DX10 is an extended header, introduced by DirectX 10.