PDA

View Full Version : Overlapping Windows and glReadPixels()



PickleWorld
03-02-2006, 05:20 AM
So before I get to my question a little info on what I am doing:

I am working with an application that must run across a long list of older graphics cards (ie no FBO's allowed, have to use the framebuffer) which needs to do a glReadPixels() call on a window which may be...

a) Partially off the screen.
b) Partially obscured by another window.

This image is then post-processed and having garbage information from sections of the framebuffer that my application does not own is causing all kinds of artifacts.

So part a) is easy enough to detect but part b) is proving a little harder. I had assumed that there would be a window's API call of some sort that would tell me which part of the screen my application still owned (eg an array of min/max screen coords or something that would allow me to do multiple glReadPixels on areas I own) but I can't seem to find one.

All the examples I can find involve using EnumWindows() and then traversing all the windows manually using various rectangle union/intersection methods.

Anyone have a better method?

Mikkel Gjoel
03-02-2006, 06:49 AM
Have you considered using Pbuffers instead? They've been around for quite some time longer than FBOs, even if they are cumbersome to use. Otherwise the enumwindows-method sounds fine. Another solution might be to do a test-drawing to detect garbage first, but I would not recommend this.

PickleWorld
03-02-2006, 08:06 AM
Have you considered using Pbuffers instead?
Same problem as FBO's, believe me I would MUCH rather just use FBO's and be done in no time, alas I can not.



Otherwise the enumwindows-method sounds fine.
Ya except that it just seemed as though having to manually traverse all the windows myself was like reinventing the wheel. I can't believe no one has needed this functionality before?



Another solution might be to do a test-drawing to detect garbage first, but I would not recommend this.
Considered doing a couple things along these lines, but I think they will all be much to slow.

tamlin
03-02-2006, 09:12 PM
For b) I think one function could be WindowFromPoint. It's likely way to slow though, why I'd probably first try UpdateWindow() followed by checking the update region on WM_PAINT.

Relic
03-02-2006, 11:16 PM
GetRandomRgn() looks like the clipping information you're looking for:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/clipping_4q0e.asp
(Interesting, didn't know that this existed.)
Beware that the information is only valid while the window is not moved.

Though the question is how to eliminate the pixels which failed the pixelownership test in the glReadPixels.
You could try to select this region for a device independent memory DC, FillRect() it, and then BitBlt() the read pixeldata there and the correct pixels would remain intact.