Przeglądaj źródła

[rl_gputex.h] Possibly fixed the swizzling in `rl_load_dds_from_memory()` function (#5422)

* Possibly fixed the swizzling bug

* Removed examples, and generation.
pull/5427/head
Michael Smith 1 dzień temu
committed by GitHub
rodzic
commit
0a4583ca54
Nie znaleziono w bazie danych klucza dla tego podpisu ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 3 dodań i 3 usunięć
  1. +3
    -3
      src/external/rl_gputex.h

+ 3
- 3
src/external/rl_gputex.h Wyświetl plik

@ -308,7 +308,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
unsigned char alpha = 0; unsigned char alpha = 0;
// NOTE: Data comes as A1R5G5B5, it must be reordered to R5G5B5A1 // NOTE: Data comes as A1R5G5B5, it must be reordered to R5G5B5A1
for (int i = 0; i < image_pixel_size; i++)
for (int i = 0; i < data_size/sizeof(unsigned short); i++)
{ {
alpha = ((unsigned short *)image_data)[i] >> 15; alpha = ((unsigned short *)image_data)[i] >> 15;
((unsigned short *)image_data)[i] = ((unsigned short *)image_data)[i] << 1; ((unsigned short *)image_data)[i] = ((unsigned short *)image_data)[i] << 1;
@ -328,7 +328,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
unsigned char alpha = 0; unsigned char alpha = 0;
// NOTE: Data comes as A4R4G4B4, it must be reordered R4G4B4A4 // NOTE: Data comes as A4R4G4B4, it must be reordered R4G4B4A4
for (int i = 0; i < image_pixel_size; i++)
for (int i = 0; i < data_size/sizeof(unsigned short); i++)
{ {
alpha = ((unsigned short *)image_data)[i] >> 12; alpha = ((unsigned short *)image_data)[i] >> 12;
((unsigned short *)image_data)[i] = ((unsigned short *)image_data)[i] << 4; ((unsigned short *)image_data)[i] = ((unsigned short *)image_data)[i] << 4;
@ -362,7 +362,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
// NOTE: Data comes as A8R8G8B8, it must be reordered R8G8B8A8 (view next comment) // NOTE: Data comes as A8R8G8B8, it must be reordered R8G8B8A8 (view next comment)
// DirecX understand ARGB as a 32bit DWORD but the actual memory byte alignment is BGRA // DirecX understand ARGB as a 32bit DWORD but the actual memory byte alignment is BGRA
// So, we must realign B8G8R8A8 to R8G8B8A8 // So, we must realign B8G8R8A8 to R8G8B8A8
for (int i = 0; i < image_pixel_size*4; i += 4)
for (int i = 0; i < data_size; i += 4)
{ {
blue = ((unsigned char *)image_data)[i]; blue = ((unsigned char *)image_data)[i];
((unsigned char *)image_data)[i] = ((unsigned char *)image_data)[i + 2]; ((unsigned char *)image_data)[i] = ((unsigned char *)image_data)[i + 2];

Ładowanie…
Anuluj
Zapisz