call to glReadPixels return garbage on some cards. This is what i do
glGenFrameBuffer()
glBindFrameBuffer()
glGenTexture()
glBindTexture()
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glBindFramebuffer()
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
render my geometry
lReadBuffer((GLenum)GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
when i loop over the returned pixels, i see some garbage values, some colors which i have not rendered at all
sorry about that, i didn’t post the entire code, in fact i do check for the completeness of the framebuffer, I generate 2 textures one for color and one for depth attachment and i do check the completeness using if(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT)
and then only render to frame buffer and then read from that framebuffer using glReadPixels
Ok I understand. try to call glFinish before reading pixels to be sure that all issued rendering commands are done. verify the packing alignment (see glPixelStore IIRC the default one is 4 (word-alignment) and usually 1 one used (byte alignment).
I did try calling glFinish with no luck, and yes, i am rendering to a texture, i checked the packing and unpacking alignment, its set to 4. i should also mention that the return of glReadPixels is not completely garbage, it looks some values in between only are junk (rather they are not matching, the color that i use to render)