SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER(3)
π SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER π
okay bestie so this is a page from the SDL3 FUNCTIONS manual, and it's all about the hint SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER. yes the name is a whole mouthful, we love her anyway π«Ά
β¨ NAME β¨
SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER β a variable that controls whether SDL forces an sRGB-capable OpenGL context, no cap.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_hints.h>
#define SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER "SDL_OPENGL_FORCE_SRGB_FRAMEBUFFER"
like, that's it. that's the whole vibe. π
π¦ DESCRIPTION π¦
so when an OpenGL context is getting created, some platforms can be like "yes bestie i can give you an sRGB-capable context β¨". but plot twist: sometimes any form of that request makes certain drivers, platforms, and hardware act absolutely unhinged. and the surprise is usually just... rendering that's a lil darker or a lil brighter than intended. not me getting jumpscared by my own pixels π
this hint is basically the fail-safe button. it lets you override whatever sRGB request the app is making, and either force a specific value or just avoid requesting anything at all β whichever one makes your particular system actually behave. π
fr fr, this is meant as a fail-safe. apps should probably not explicitly set this, and most users should not either. it's giving "break glass in case of emergency". π¨
also important: some platforms literally cannot make this request at all, and on all platforms the operating system can just be like "no π" and deny it.
and on top of trying to get the kind of sRGB-capable OpenGL context that this hint asks for, SDL will also try to force the state of GL_FRAMEBUFFER_SRGB on the new context, if that's appropriate. slay.
the variable can be set to these values:
"0"β force a request for an OpenGL context that is not sRGB-capable."1"β force a request for an OpenGL context that is sRGB-capable."skip"β don't make any request for an sRGB-capable context at all (meaning: don't specify the attribute at all during context creation time). just walk away, no notes. π- any other string β undefined behavior. do not do this. i'm serious. π
if it's unset, or set to an empty string, SDL will make a request using the value the app specified with the SDL_GL_FRAMEBUFFER_SRGB_CAPABLE attribute. so it just trusts the app at that point. bestie energy.
timing matters, queen: this hint should be set before an OpenGL context is created. setting it after is not it. π
π AVAILABILITY π
this hint has been available since SDL 3.4.2. so if you're on anything older... upgrade, bestie. β¨
and that's the whole page!! brought to you by the iconic legends at Simple Directmedia Layer, SDL 3.4.18 edition. go forth and have a correctly-coloured framebuffer, mwah πππ¦π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms