View Full Version : ReadPixels for integer FBO

02-18-2010, 09:42 AM
I'm trying to read a single pixel from the (format=RedInteger, type=Byte, intformat=R8ui) texture. ReadPixels returns without GL errors but doesn't change the value I pass, somehow.

GL.BindFramebuffer(FramebufferTarget.Framebuffer, fbo_id)
GL.ClearBuffer(ClearBuffer.Color, 0, (of uint:10,10,10,10))
//some drawing code
GL.ReadBuffer( ReadBufferMode.ColorAttachment0 )
GL.BindBuffer( BufferTarget.PixelPackBuffer, 0 )
val = (of byte: 20,)
GL.ReadPixels(coord[0],coord[1],1,1, PixelFormat.RedInteger, PixelType.Byte, val)

The val[0] remains 20 after the ReadPixels call, what clearly shows that it hasn't been touched at all.
The coord[0:2] values are in range of the buffer.

Environment: winxp, Catalyst 9.10, opentk, GL 3.1 pure context.
Does anyone has an idea about that?

Thanks in advance,

Pierre Boudier
02-18-2010, 03:35 PM
just to make sure, your read fbo has an integer format ? (there should be an error otherwise because no float<->int conversion is allowed)

02-19-2010, 06:24 AM
The arguments of GL.TexImage2D (in terms of OpenTK) are:
TextureTarget.Texture2D (0xde1) = GL_TEXTURE_2D
PixelFormat.RedInteger (0x8d94) = GL_RED_INTEGER
PixelType.UnsignedByte (0x1401) = GL_UNSIGNED_BYTE
PixelInternalFormat.R8ui (0x8232) = GL_R8UI

I believe that defines an unsigned integer 1-channel byte 2D texture.
This texture is attached to ColorAttachment0 of the FBO, which also has a standard 24bit fixed point depth buffer (same resolution).