Important: Please read the Qt Code of Conduct -

Gamma correction: glEnable(GL_FRAMEBUFFER_SRGB) has no effect

  • I set up surface and texture format in QOpenGLWidget's ctor like this:

    QSurfaceFormat format;

    With that, gamma correction is applied to the fragment shader output in the default FBO. At least, I can make a screenshot and get some pixel color, and it is approximately (1/2.2)-th power of the fragment shader's output color.

    When I put glEnable(GL_FRAMEBUFFER_SRGB) or glDisable(GL_FRAMEBUFFER_SRGB) anywhere, it makes no difference. As far as I know, it is supposed to turn gamma correction on/off, but it does no such thing.

    Yet on my other machine that same program produces output with gamma correction applied TWICE to it — all in the drawing operation writing to the default FBO. I need to put glDisable(GL_FRAMEBUFFER_SRGB) before it in order to make gamma correction applied only once.

    Why it works that way? And how do I make my program work right on any device?

  • Lifetime Qt Champion


    What graphic stack do you have on your devices ?
    What version of Qt ?
    What OS ?

  • OS is Windows 10 on both machines. It is the latest version of Qt (Qt updater informs me whenever new updates are available). Don't know what graphic stack is, but I have GeForce GTX 1050 with 2Gb RAM and OpenGL 4.6. QOpenGLFunctions_4_5_Core is used to call OpenGL functions.

  • You may see the whole source code here.
    Sorry I've forgot to mention it. The main part of rendering is in GLWidget.cpp file.

Log in to reply