Fix swizzle values for some memory formats
authorMatthias Clasen <mclasen@redhat.com>
Thu, 26 Oct 2023 01:39:52 +0000 (21:39 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 17 Nov 2023 19:53:41 +0000 (14:53 -0500)
For opaque formats with 3 channels, we should use the default
GL_ALPHA, but for opaque formats with an ignored 4th channel,
we must use GL_ONE.

gdk/gdkmemoryformat.c

index 3b21734c14405e2b1edad5900f88d46fb05d9dd7..61ef3a5a4213be054975af37601c914c01ee8585 100644 (file)
@@ -423,7 +423,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
     G_ALIGNOF (guchar),
     GDK_MEMORY_U8,
     { 0, 0, 0, 0 },
-    { GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
+    { GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
     r8g8b8_to_float,
     r8g8b8_from_float,
   },
@@ -433,7 +433,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
     G_ALIGNOF (guchar),
     GDK_MEMORY_U8,
     { 0, 0, G_MAXUINT, G_MAXUINT },
-    { GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
+    { GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
     b8g8r8_to_float,
     b8g8r8_from_float,
   },
@@ -443,7 +443,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
     G_ALIGNOF (guint16),
     GDK_MEMORY_U16,
     { 0, 0, 3, 0 },
-    { GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
+    { GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
     r16g16b16_to_float,
     r16g16b16_from_float,
   },
@@ -473,7 +473,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
     G_ALIGNOF (guint16),
     GDK_MEMORY_FLOAT16,
     { 0, 0, 3, 0 },
-    { GL_RGB16F, GL_RGB, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
+    { GL_RGB16F, GL_RGB, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
     r16g16b16_float_to_float,
     r16g16b16_float_from_float,
   },
@@ -503,7 +503,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
     G_ALIGNOF (float),
     GDK_MEMORY_FLOAT32,
     { 0, 0, 3, 0 },
-    { GL_RGB32F, GL_RGB, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
+    { GL_RGB32F, GL_RGB, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
     r32g32b32_float_to_float,
     r32g32b32_float_from_float,
   },