Offscreen rendering problem


I’m doing offscreen rendering by creating a hidden window using CreateWindowEx() and then copying the result to a block of memory using glReadPixels.

The data is then used for image processing, texturing and saving to file. It’s Windows only and works fine on modern hardware (ATI + nVidia) that I’ve tried but on older gfx cards or cards with old drivers the glReadPixels call always returns an image of the Windows desktop instead of what should have been rendered into the hidden window.

I need it to work on this legacy hardware but don’t want to render to a DIB bitmap because that would revert to unaccelerated OpenGL 1.1.

Is the desktop’s framebuffer shared with the offscreen window on some hardware and if so is there any way to use a seperate hidden window for rendering (with a different rendering context of course)?

I could use pbuffers but would rather allow this to work with hardware that does not support them and I can’t use FBO’s or Mesa3D.


can’t use FBO : really ? then you are screwed. Out of old pbuffers or FBO, anything non visible is undefined, because of the pixel ownership rules. Undefined means you can not rely on it.

FBO is supported even on old cards, only the driver must be somewhat recent.

My ‘legacy’ test card is a GeForce4 MX440 (OpenGL 1.3.1 I think) which with the current drivers does not support FBO’s. It may do if I updated them, I don’t know. But, I need my code to work on really low-end hardware, for instance integrated Intel chipsets, which I’ve read have very patchy support for FBO’s and pbuffers.

I’ve read quite a few articles giving examples of the ‘hidden window approach’ (can’t find any links now), but it sounds like it will never guarantee correct results.

Geforce 4 MX is even less capable than a geforce3, is nearly 8 years old, and drivers are not supported anymore by Nvidia…

About Intel integrated crap, the funny thing is that on Mac and linux there is support for FBO… And apparently not on Windows.

With such constraints, you will have to abandon hardware-accelerated windowless rendering … Can you share more details about your needs ?

Yes it is very old, but is the minimum I want to support, and would in reality be rarely used. I need to compile textures together (no more than simple blending) and do rendering in a windowless application (maybe on a server).

I think the strategy I’ll use is to try and use pbuffers/FBOs if they are present, and fallback to unaccelerated rendering to a DIB if not.