Skip to content

Commit 1a67dcb

Browse files
committed
REVIEWED: RGB order on SDL3 raysan5#3568
1 parent d4202a0 commit 1a67dcb

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

src/platforms/rcore_desktop_sdl.c

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -702,70 +702,84 @@ void SetWindowIcon(Image image)
702702
switch (image.format)
703703
{
704704
case PIXELFORMAT_UNCOMPRESSED_GRAYSCALE:
705+
{
705706
rmask = 0xFF, gmask = 0;
706707
bmask = 0, amask = 0;
707708
depth = 8, pitch = image.width;
708-
break;
709+
} break;
709710
case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA:
711+
{
710712
rmask = 0xFF, gmask = 0xFF00;
711713
bmask = 0, amask = 0;
712714
depth = 16, pitch = image.width*2;
713-
break;
715+
} break;
714716
case PIXELFORMAT_UNCOMPRESSED_R5G6B5:
717+
{
715718
rmask = 0xF800, gmask = 0x07E0;
716719
bmask = 0x001F, amask = 0;
717720
depth = 16, pitch = image.width*2;
718-
break;
719-
case PIXELFORMAT_UNCOMPRESSED_R8G8B8: // Uses BGR for 24-bit
720-
rmask = 0x0000FF, gmask = 0x00FF00;
721-
bmask = 0xFF0000, amask = 0;
721+
} break;
722+
case PIXELFORMAT_UNCOMPRESSED_R8G8B8:
723+
{
724+
// WARNING: SDL2 could be using BGR but SDL3 RGB
725+
rmask = 0xFF0000, gmask = 0x00FF00;
726+
bmask = 0x0000FF, amask = 0;
722727
depth = 24, pitch = image.width*3;
723-
break;
728+
} break;
724729
case PIXELFORMAT_UNCOMPRESSED_R5G5B5A1:
730+
{
725731
rmask = 0xF800, gmask = 0x07C0;
726732
bmask = 0x003E, amask = 0x0001;
727733
depth = 16, pitch = image.width*2;
728-
break;
734+
} break;
729735
case PIXELFORMAT_UNCOMPRESSED_R4G4B4A4:
736+
{
730737
rmask = 0xF000, gmask = 0x0F00;
731738
bmask = 0x00F0, amask = 0x000F;
732739
depth = 16, pitch = image.width*2;
733-
break;
740+
} break;
734741
case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8:
742+
{
735743
rmask = 0xFF000000, gmask = 0x00FF0000;
736744
bmask = 0x0000FF00, amask = 0x000000FF;
737745
depth = 32, pitch = image.width*4;
738-
break;
746+
} break;
739747
case PIXELFORMAT_UNCOMPRESSED_R32:
748+
{
740749
rmask = 0xFFFFFFFF, gmask = 0;
741750
bmask = 0, amask = 0;
742751
depth = 32, pitch = image.width*4;
743-
break;
752+
} break;
744753
case PIXELFORMAT_UNCOMPRESSED_R32G32B32:
754+
{
745755
rmask = 0xFFFFFFFF, gmask = 0xFFFFFFFF;
746756
bmask = 0xFFFFFFFF, amask = 0;
747757
depth = 96, pitch = image.width*12;
748-
break;
758+
} break;
749759
case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32:
760+
{
750761
rmask = 0xFFFFFFFF, gmask = 0xFFFFFFFF;
751762
bmask = 0xFFFFFFFF, amask = 0xFFFFFFFF;
752763
depth = 128, pitch = image.width*16;
753-
break;
764+
} break;
754765
case PIXELFORMAT_UNCOMPRESSED_R16:
766+
{
755767
rmask = 0xFFFF, gmask = 0;
756768
bmask = 0, amask = 0;
757769
depth = 16, pitch = image.width*2;
758-
break;
770+
} break;
759771
case PIXELFORMAT_UNCOMPRESSED_R16G16B16:
772+
{
760773
rmask = 0xFFFF, gmask = 0xFFFF;
761774
bmask = 0xFFFF, amask = 0;
762775
depth = 48, pitch = image.width*6;
763-
break;
776+
} break;
764777
case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
778+
{
765779
rmask = 0xFFFF, gmask = 0xFFFF;
766780
bmask = 0xFFFF, amask = 0xFFFF;
767781
depth = 64, pitch = image.width*8;
768-
break;
782+
} break;
769783
default: return; // Compressed formats are not supported
770784
}
771785

0 commit comments

Comments
 (0)