The documentation of SDL does not seem to mention much about color spaces. I don't see any SRGB flag/parameter for SDL_SetVideoMode
or SDL_GL_SetAttribute
. Is it possible at all for SDL to ask OpenGL to perform the color correction when writing on the FrameBuffer 0? GLUT seems to be able to provide that functionality.
If SDL cannot do it, what is the usual workaround? I am considering rendering to a sRGB texture with GL_FRAMEBUFFER_SRGB
enabled, and then rendering that into the FrameBuffer 0 with FRAMEBUFFER_SRGB
disabled. Any better idea?
Sorry to revive an old question here, but I wanted to note that SDL 2.0.1 will explicitly let you request an sRGB context:
SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
// etc.
SDL_Window *win = SDL_CreateWindow(...);
SDL_GL_CreateContext(win);
This works on Windows and X11 (Mac OS X, etc, doesn't offer this functionality at the moment). It's worth noting that, before SDL 2.0.1 offered this, most GL contexts on modern hardware are already sRGB capable by default. But there you go.
To be slightly more precise:
You just need to call glEnable(GL_FRAMEBUFFER_SRGB)
to make Framebuffer 0 into an SRGB framebuffer.
If you are on SDL2, you should request the capability by calling SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1)
during init, but if you are on an earlier version of SDL, it seems that right now graphics drivers do not care if you request it beforehand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With