glReadPixels and Win NT screen saver

Hi,

I am developing a Win NT application which is designed to generate an MPEG file by spawning a UI thread to run in the background, then repeatedly:

  1. generate a scene in the back buffer
  2. use glReadPixels to get the image from the back buffer
  3. pass the pixel data to a third-party tool for generating MPEGs
  4. adjust the position of my “observer”
  5. repeat until I have “moved” through all the way through my scene

All of this works fine as a background process under normal conditions. My problem is, when the screen saver kicks in, I find that the glReadPixels command is no longer populating my pixel array with ANY data (it doesn’t touch my pixel array and leaves the same image as was there previously).

Does anyone know why this would happen?

Thanks,
Bob

Is it one of the OpenGL screensavers? If so it’ll have its own rendering context, so yours will become noncurrent as soon as the screensaver kicks in. Without a current RC, pretty much any OpenGL call will fail.

The screen saver isn’t OpenGL - based. Also, within my application thread, whenever I need to build a new frame of pixel data, I make sure to make my rendering context current, using “wglMakeCurrent.”

Further, I use “glGetError” at several places within my code to test for that sort of error, but I’m not getting any.

As far as I remeber you can manualy override the screensaver using the:

SystemParametersInfo( SPI_SETSCREENSAVEACTIVE,FALSE,NULL, 0 );

command on your programm startup. When you existing your programm you should call

SystemParametersInfo( SPI_SETSCREENSAVEACTIVE,TRUE,NULL, 0 );

to renable it…

Hope that helped.

LG

check it out!

[QUOTE]Originally posted by BobH:
[b]Hi,

I am developing a Win NT application [which spawns] a UI thread to run in the background, then repeatedly:

  1. generate a scene in the back buffer
  2. use glReadPixels to get the image from the back buffer
  3. pass the pixel data to a third-party tool for generating MPEGs
  4. adjust the position of my “observer”
  5. repeat until I have “moved” through all the way through my scene

All of this works fine as a background process under normal conditions. My problem is, when the screen saver kicks in, I find that the glReadPixels command is no longer populating my pixel array with ANY data (it doesn’t touch my pixel array and leaves the same image as was there previously).

I am having the identical problem with my MFC app. I am using an Elsa Erazor X^2 card (nVidia GeForce 256 GPU), using what I believe are the latest nVidia drivers, downloaded straight from nVidia’s web site.

I am checking the return code of all the Win32 calls I make (wglMakeCurrent, etc…) + I am calling glGetError() after every GL function call I issue.

What I have found is that my app will run fine for hours on end until I bring up the Windows Explorer and quickly move it around and around with the mouse. And then sure enough, each and every time glReadPixels doesn’t populate my array like it should. In fact, I have noticed that it fills it with some test pattern or something. Kinda looks like the emergence broadcast network pattern you used to see on your TV screens way back when.

So, any ideas? This is driving me nuts!

An obscured window is not guaranteed to even have a framebuffer to read from…

ReadPixels is not trustworthy unless the window is visible and in the foreground.

  • Matt

Indeed, and thanks for your help!
To fix my code I inserted a call to the Win32 function SetForegroundWindow() inside my rendering loop. Voila, works like a charm!