View Full Version : Valid context when canvas is hidden?

11-12-2008, 03:04 PM
I have a question about what happens when my ogl canvas is behind some other window.

I have an OpenGL app for which rendering takes quite some time (say 10 or 20 seconds, I use LOD and continuously refine to reach the final image).

To offset the slow rendering, when rendering completes I capture an image of the canvas and use that on the next repaint when possible.

But if my ogl canvas is partially or fully covered by some other app, when I capture the image the parts of the canvas that were behind other apps are garbage. I need to detect this and decide to redraw the canvas instead of using the captured image in these situations.

So how can I tell if my ogl canvas is covered by some other app while I'm drawing? I tried checking the current DC and context and they don't change. Does OpenGL have this information, or do I need to get it from my windowing system?
I am very confused.


11-12-2008, 03:05 PM
Use true offscreen rendering (framebuffer object), which will not be impacted by pixer ownership test.

11-12-2008, 03:33 PM
That sounds good ... do you have a good reference or example?

I would guess that I basically have to:
- create a new framebuffer object
- make the framebuffer current
- do normal rendering calls
- then copy pixels from the framebuffer to the screen buffer?

11-12-2008, 03:50 PM
There's plenty of FBO tutorials around. Google up "opengl fbo tutorial".

11-12-2008, 04:11 PM
Thanks, I would not have thought to try "FBO" instead of "framebuffer".

11-13-2008, 02:41 AM
had this and updating the drivers helped. of course for commercial software not every user will update the drivers on there own so FBO's are pretty good choice or pbuffers which are supported by some really oldschool cards.

11-13-2008, 06:16 AM