Does `SDL_SetRenderDrawColor` use sRGB color?
It's unclear if inputs to SDL_SetRenderDrawColor should be sRGB values or linear values.
I don't think SDL_Render has any API to enable RGB linearization / gamma-correction, so the entire pipeline would be sRGB including the draw color.
That's basically fine if so, but should go in the docs.
(aside: I at least hope the blends happen in linear space)
Blending will also be sRGB because there's no conversion between sRGB and linear RGB at all in the pipeline.
If that's a feature that gets added to SDL_Render in the future it would probably have to be optional and opt-in, since various older devices don't support hardware sRGB/linear conversions and having the conversions versus not having them affects the visual end result.
Oh uh that's... very unfortunate if true. It's basically just fundamentally incorrect to do any blends in the gamma adjusted sRGB space.
Indeed mixing sRGB-encoded colours instead of linear RGB isn't how physical reality behaves. But sometimes doing colour math in linear RGB isn't desired either (for example oklab / perceptual gradient blending is getting popular these days in various tools, and depending on background and foreground colour combinations antialiased text rendering can look worse with linear RGB blending than sRGB).
In any case, if you have a specific project or example that uses SDL_Render and can be demonstrated to look better with linear blending rather than sRGB blending, it might go a long way toward getting the opt-in feature included in SDL_Render down the road.
Using a lower level API than SDL_Render together with SDL (for example OpenGL) will also let you use hardware sRGB<->linear conversions.
Yes. With my Rust bindings I've been using SDL with OpenGL, but a user asked that I also add methods for using the SDL_Renderer to the bindings library. I mostly needed to know for documentation.
In terms of showing a specific example, if SDL doesn't even have an option to perform blending in linear space I'm not sure how I'd make an example comparing the two.
I believe we use linear RGB in the SDL renderer. I'm going to be working on HDR soon, so I'll make sure this is the case and add a hint for sRGB.
FYI, I did some investigation and we're using sRGB in the renderer, and also doing alpha blending in the sRGB space with the software renderer. Recent SDL3 code now uses linear blending in some of the renderers, and we're still debating whether we want that to be the default.
So it's official, and documented, SDL uses sRGB by default, but you can request the scRGB colorspace with at least the direct3d11 and direct3d12 renderers, which will put you into a linear colorspace with HDR support. https://github.com/libsdl-org/SDL/blob/e67e0c5d55874d4b18def5709ce8c25934073700/include/SDL3/SDL_pixels.h#L562 https://github.com/libsdl-org/SDL/blob/e67e0c5d55874d4b18def5709ce8c25934073700/include/SDL3/SDL_render.h#L243-L247