Hi,
I have an FBO with a single color attachment, which is a GL_RGBA16F texture.
Whevener I call glClearColor with values > 1, I get the good result on NVidia boards, clearing with the HDR values, and a value clamped to 1 on ATI boards.
I tried to play with glClampColor calls without much success.
I was wondering which is the good default behaviour ? Is there any specific call to instruct GL to have a proper unclamped clear color ?
Some quick unit test I wrote with Python & PyOpenGL is below. The second ‘glReadPixelsf’ returns (1,1,0,1) instead of (1,2,0,1).
Any help would be greatly appreciated !
Cheers,
width = 512
height = 512
glutInit()
glutInitWindowSize(512, 512)
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH)
win = glutCreateWindow("Test")
texture_id = glGenTextures(1)
glBindTexture(GL_TEXTURE_2D, texture_id)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, None)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
glBindTexture(GL_TEXTURE_2D, 0)
# bind / create
fbo = glGenFramebuffersEXT(1)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, int(fbo))
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texture_id, 0)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
# use
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, int(fbo))
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT)
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT)
currentBufferStatus = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
if (currentBufferStatus != GL_FRAMEBUFFER_COMPLETE_EXT):
print "glCheckFramebufferStatusEXT = 0x%x" % currentBufferStatus
self.assertEquals(currentBufferStatus, GL_FRAMEBUFFER_COMPLETE_EXT)
# test
glClearColor(1.0, 1.0, 0.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT)
colors = glReadPixelsf(0, 0, 1, 1, GL_RGBA)
pixel = _get_pixel(colors)
self.assertEquals( pixel[0], 1.0 )
self.assertEquals( pixel[1], 1.0 )
self.assertEquals( pixel[2], 0.0 )
self.assertEquals( pixel[3], 1.0 )
glClearColor(1.0, 2.0, 0.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT)
colors = glReadPixelsf(0, 0, 1, 1, GL_RGBA)
pixel = _get_pixel(colors)
self.assertEquals( pixel[0], 1.0 )
self.assertEquals( pixel[1], 2.0 )
self.assertEquals( pixel[2], 0.0 )
self.assertEquals( pixel[3], 1.0 )
# unbind
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
glutDestroyWindow(win)