summaryrefslogtreecommitdiffhomepage
path: root/src/external
diff options
context:
space:
mode:
authorJaanDev <[email protected]>2023-10-29 22:21:00 +0300
committerGitHub <[email protected]>2023-10-29 20:21:00 +0100
commit1fd61a00e4423c68f2b32c46148847b27a6eb94f (patch)
tree6b3fd3806e45d466362debbef1d528d3279c5d1b /src/external
parent12f3bc10c2def80abfc76c8158785ac91c0ca1d1 (diff)
downloadraylib-1fd61a00e4423c68f2b32c46148847b27a6eb94f.tar.gz
raylib-1fd61a00e4423c68f2b32c46148847b27a6eb94f.zip
Fix compressed DDS texture loading issues (#3483)
Diffstat (limited to 'src/external')
-rw-r--r--src/external/rl_gputex.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/external/rl_gputex.h b/src/external/rl_gputex.h
index fa39fe29..fb7b5e8d 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));