From 25f281898a290ebb3ab20785d6a8108d04727c84 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 16 Oct 2026 16:22:23 -0700
Subject: [PATCH] testcolorspace: explain why the drawn and texture gradients
differ
---
test/testcolorspace.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/test/testcolorspace.c b/test/testcolorspace.c
index fbb269311d931..1969379dcdf08 100644
--- a/test/testcolorspace.c
+++ b/test/testcolorspace.c
@@ -814,6 +814,18 @@ static void RenderGradientDrawing(void)
DrawGradient(x, y, WINDOW_WIDTH - 2 * x, 64.0f, 0.0f, 1.0f);
SDL_SetRenderColorScale(renderer, 1.0f);
y += 64.0f;
+
+ y += TEXT_LINE_ADVANCE;
+ y += TEXT_LINE_ADVANCE;
+
+ /* Vertex colors are interpolated in the colorspace of the output */
+ if (colorspace == SDL_COLORSPACE_SRGB) {
+ DrawText(x, y, "Interpolating in sRGB space, so this is darker than the texture gradient");
+ y += TEXT_LINE_ADVANCE;
+ } else {
+ DrawText(x, y, "Interpolating in linear space, so this matches the texture gradient");
+ y += TEXT_LINE_ADVANCE;
+ }
}
static SDL_Texture *CreateGradientTexture(int width, float start, float end)
@@ -884,6 +896,18 @@ static void RenderGradientTexture(void)
/* The gradient texture is in the linear colorspace, so we can use the HDR_headroom value directly */
DrawGradientTexture(x, y, WINDOW_WIDTH - 2 * x, 64.0f, 0.0f, HDR_headroom);
y += 64.0f;
+
+ y += TEXT_LINE_ADVANCE;
+ y += TEXT_LINE_ADVANCE;
+
+ /* The texture contains linear values, so it looks the same in every output colorspace */
+ if (colorspace == SDL_COLORSPACE_SRGB) {
+ DrawText(x, y, "Rendering linear values, so this is lighter than the drawn gradient");
+ y += TEXT_LINE_ADVANCE;
+ } else {
+ DrawText(x, y, "Rendering linear values, so this matches the drawn gradient");
+ y += TEXT_LINE_ADVANCE;
+ }
}
float PQfromNits(float v)