PDA

View Full Version : glReadPixels behavior with multi windows/contexts



rockeye
09-22-2009, 02:59 AM
Hi,

I am currently experiencing some annoying results with glReadPixels. I would like to know if i am doing something wrong/forbidden.

I develop under Windows, but I guess this is OS-independent.
I have 2 OpenGL windows, with distinct contexts which share lists.
Windows are double buffered.
I can't use FBO to support prehistoric OpenGL cards. :'(

Window1 is displayed (Window2 hidden), and i would like to render in the Windows2 back buffer, and read it.

But glReadPixels always returns the window1 back buffer whereas the objects are rendered into the window2 back buffer!

In the glReadPixels sdk page, a note specifies :
"Values for pixels that lie outside the window connected to the current GL context are undefined."

In my process, the current GL context is connected to the hidden window2, but i get window1 pixels... O.o

I wonder if glReadPixels can read pixels in another window than the current one ?
Do I miss something?

Thanks

Stephen A
09-22-2009, 04:19 AM
The framebuffer contents of an invisible or obscured window are undefined. In other words, reading back from Window2 will not work reliably no matter what you try.

You will need to use a pbuffer or FBO for offscreen rendering.