About glReadPixel & double buffering
in my codes:
after 3 x glutswapbuffer(), I found that the framebuffer i got via glreadpixel is not the same as shown on the screen
What is the reason?
Should I point to the front buffer or the back buffer?
In fact, I just want to get the content which shown on the current screen.
Re: About glReadPixel & double buffering
Put glReadBuffer(GL_FRONT) once before the glReadPixels and you read what you see.
In double buffered contexts the glDrawBuffer and the glReadBuffer are both defaulting to GL_BACK.
After a SwapBuffers don't assume the backbuffer contents to be still valid. There is a hint in the dwFlags of the PIXELFORMATDESCRIPTOR which says if the format copies or can swap, those are named PFD_SWAP_COPY and PFD_SWAP_EXCHANGE.
Don't assume pixels overlapped by other windows or moved off the desktop to give useful data on readback. Those fail the pixelownership test and are mostly bogus.