View Full Version : glRead/drawpixels over FBO
Boschiotto4
06-13-2007, 03:42 AM
I want to read all the pixel of my offscreen render, but when I call the glreadpixels, it returns to me only the window pixel value, and not the offscreen pixel's value.
First I think that it can be for an incorrect FBO setup, but I had not found any error.
So I want to know if glreadpixel read all the buffer or not..
mfort
06-13-2007, 04:18 AM
Be sure you call glBindFramebuffer with valid FBO before glReadPixels.
It works fine for me (NV cards).
Beware: glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0)
will switch back to reading from Window.
Boschiotto4
06-13-2007, 06:58 AM
I've call glbindframebuffer before glreadpixels, but it read nonsense value..this is my config:
FOR GLREADPIXELS:
glReadPixels(0, 0, dimX, dimY, GL_RGBA, GL_FLOAT, imagePixels);
AND THIS IS THE TEXTURE FBO:
glBindTexture(GL_TEXTURE_2D, color_tex);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, dimX, dimY, 0,
GL_RGBA8, GL_FLOAT, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, color_tex, 0);
somethings wrong?
dimensionX
06-13-2007, 08:45 AM
1) BindFBO(true)
2) glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
3) glReadPixels()
4) BindFBO(false)
Also, when you Bind a texture make sure which texture unit is active or just say glActiveTexture(GL_TEXTURE0) or some other texture unit. These are common mistake easily overlooked.
You dont' seem to initialize the contents of the texture.
Boschiotto4
06-14-2007, 01:20 AM
What did you mean with "context of the texture"?
I follow your istruction and I make a little step over, but my offscreen render seems to working wrong. Maybe for this "context of the texture"?
mfort
06-14-2007, 03:47 AM
Your FBO is probably not complete.
After glFramebufferTexture2D()
call following to be sure the FBO is OK.
GLenum status;
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if(status != GL_FRAMEBUFFER_COMPLETE_EXT) {
// report error
}
Olivier B.
06-14-2007, 06:18 AM
I think FBO isn't complete because in
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, dimX, dimY, 0, GL_RGBA8, GL_FLOAT, NULL); the second GL_RGBA8 isn't a correct value but GL_RGBA is.
Boschiotto4
06-14-2007, 07:11 AM
My FBO seems to be ok, this is my problem:
Render off-screen
- 1)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,mRenderer. fb);
glDrawElements( GL_TRIANGLES, kNumVertices, GL_UNSIGNED_INT, &mTriBufferIndices[0] ); - 2)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb);
glReadPixels(0, 0, dimX, dimY, GL_RGBA, GL_FLOAT, imagePixels);- 3) Draw the pixel
but that pixel are incomplete, in fact in the offscreen rectangle there's only the window clear color without the 3D image. So when I call gldrawelements with previosly the glbindframebufferEXT, the 3D object seems to disappear..while if I use only the gldrawelements without the glbindframebufferEXT the 3D object is rendered on the window(but maybe not in the offscreen buffer).
Any idea? thanks..
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.