SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER(3)

πŸ“¦
version 3.4.18 Β· 4 versions
, in fedora 43, fedora 44

πŸ’… 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