Important: Please read the Qt Code of Conduct -

GlClampColor missing in QT

  • Hello All,

    I'm working on a Render to Texture in QT with QGLWidget and a QGLFramebufferObject. My intention is to write floating point values to the texture via a shader.

    I use a GL_RGB32F texture and the RTT seems to be happening. However, the values stored in the texture seem to be clamped between 0 and 1.

    A test value of gl_FragData[0] = vec4(120.0, 2.0, 0.8, 1.0); in the shader results in 1.0, 1.0, 0.8 in the texture.

    I see posts that suggest that calls to glClampColor


    will get rid of this clamping, but unfortunately I'm not able to find this call in QT 5.0.2. It seems to be removed after QT 4.3 inside QOpenGLFunctions

    How can I achieve this? Any help would be much appreciated.

  • Non-QT related answer, but how do you inspect the values? If you download the texture using glReadPixels, then the clamping may very well occur while downloading (see e.g. glPixelTransfer). Perhaps you should try glGetTexImage.

  • Thanks! glGetTexImage seemed to help. It is a bit slower, but works nevertheless.

Log in to reply