开发者

obtaining full desktop screenshot from the GPU

开发者 https://www.devze.com 2023-03-15 20:55 出处:网络
I have been using the Windows API\'s BitBlt function to perform the screen grab. There are many drawbacks however:

I have been using the Windows API's BitBlt function to perform the screen grab.

There are many drawbacks however:

  1. DWM and Aero cause a massive slowdown (3ms --> 35ms just to call BitBlt) -- to work around this would require disabling Aero which I'd just rather not do. The screen flickers and things shift around.
  2. Data must be re-transferred to the GPU in order to load data as texture
  3. Layered Windows cannot be captured without 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号