From c629b16ebce5c8e7b2d8e2a3e842b069965bd6be Mon Sep 17 00:00:00 2001 From: raysan5 Date: Mon, 12 Aug 2019 12:35:23 +0200 Subject: [PATCH] Corrected issue on compressed textures data size --- src/rlgl.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rlgl.h b/src/rlgl.h index aa0c5e144..5e7312bde 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -4623,6 +4623,14 @@ int GetPixelDataSize(int width, int height, int format) } dataSize = width*height*bpp/8; // Total data size in bytes + + // Most compressed formats works on 4x4 blocks, + // if texture is smaller, minimum dataSize is 8 or 16 + if ((width < 4) && (height < 4)) + { + if ((format >= COMPRESSED_DXT1_RGB) && (format < COMPRESSED_DXT3_RGBA)) dataSize = 8; + else if ((format >= COMPRESSED_DXT3_RGBA) && (format < COMPRESSED_ASTC_8x8_RGBA)) dataSize = 16; + } return dataSize; }