From 1fd61a00e4423c68f2b32c46148847b27a6eb94f Mon Sep 17 00:00:00 2001 From: JaanDev <67502867+JaanDev@users.noreply.github.com> Date: Sun, 29 Oct 2023 22:21:00 +0300 Subject: [PATCH] Fix compressed DDS texture loading issues (#3483) --- src/external/rl_gputex.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/external/rl_gputex.h b/src/external/rl_gputex.h index fa39fe29c..fb7b5e8de 100644 --- a/src/external/rl_gputex.h +++ b/src/external/rl_gputex.h @@ -261,11 +261,9 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_ } else if (((header->ddspf.flags == 0x04) || (header->ddspf.flags == 0x05)) && (header->ddspf.fourcc > 0)) // Compressed { - int data_size = 0; - - // Calculate data size, including all mipmaps - if (header->mipmap_count > 1) data_size = header->pitch_or_linear_size*2; - else data_size = header->pitch_or_linear_size; + // NOTE: This forces only 1 mipmap to be loaded which is not really correct but it works + int data_size = (header->pitch_or_linear_size < file_size - 0x80) ? header->pitch_or_linear_size : file_size - 0x80; + *mips = 1; image_data = RL_MALLOC(data_size*sizeof(unsigned char));