I have been using the Windows API's BitBlt
function to perform the screen grab.
There are many drawbacks however:
BitBlt
) -- to work around this would require disabling Aero which I'd just rather not do. The screen flickers and things shift around. CAPTUREBLT
flag. When enabled, the mouse cursor blinks when capturing. This may seem like a minor issue, but it is exceedingly annoying when the application is otherwise bug-free. As a workaround for this I intend to render a layered window as an additional cursor. I am already using OpenGL to display and manipulate the captured screen data. BitBlt
gives me the pixel data and it is relatively easy to load it into a texture. However this is slightly absurd because I am manually re-sending the data back to the GPU when it should be available on the GPU to begin with. The data most certainly is there, but trying to access it is a different matter.
I presume that this functionality is not high on the to-do list (or likely on any list for that matter) for vendors but I would like to ask those in the know if there are any provisions at all provided by AMD(ATI) or NVidia in their drivers for reading the screen buffer (into an OpenGL context for instance). I simply do not know enough about modern GPU architecture to know where to start digging for answers.
OpenGL can only read the context framebuffer (a window), and any framebuffers or pbuffers you have created. OpenGL cannot touch the desktop or any other window.
This is an interesting question. Unfortunately I don't think this is really supported. I have found reports of some level of success with creating a full screen invisible window and reading the pixel data with glReadPixels:
http://www.virtualdub.org/blog/pivot/entry.php?id=142
http://www.opentk.com/node/2430
However, I believe the behavior when doing this is undefined and will only work on specific hardware/OS configurations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With