libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.92k stars 1.84k forks source link

Feature request: SDL_SetRendererGammaRamp(), affecting final SDL_RenderPresent() #4710

Open ell1e opened 3 years ago

ell1e commented 3 years ago

After reading SDL_SetWindowGammaRamp() and SDL_SetWindowBrightness, I have wondered if both aren't a bit archaic. Don't most modern OpenGL/Vulkan apps do internal LUT/color mapping anyway which can trivially include gamma correction? This left me to realize that this is however currently completely unavailable to programs using SDL_Renderer which would potentially affect a huge bunch of 2D games, even though the render backends also use shaders under the hood that could apply this almost for free even on slower mobile GPUs. Since reliable ingame gamma settings (and my user experience with the display-focused ones has been that they are not reliably available) can be considered an accessibility feature, I think it'd be great if that was changed.

I am therefore suggesting a SDL_SetRendererGammaRamp(SDL_Renderer *renderer, const Uint16 * red, const Uint16 * green, const Uint16 * blue); which should apply the gamma correction as soon as any operations reach the final window render target. I would expect it to affect SDL_RenderReadPixels too, and find that an acceptable or even natural consequence. I would find this new gamma thing useful even if the software renderer didn't support this new functionality, but ideally it also would (even assuming in software it would cause a much bigger performance hit).

slouken commented 3 years ago

That seems like a good idea. Do you want to submit a PR?

ell1e commented 3 years ago

I'm actually quite bad with the 3d accelerated graphics APIs :joy: which is why I like SDL Renderer so much. So at this point I don't think I will dare to implement this myself :eyes:

slouken commented 3 years ago

grin I totally understand. Well, I'll leave this bug report here in case anyone else wants to take a crack at it.