Capture desktop to Texture

Started by
2 comments, last by gsamour 12 years, 9 months ago
Hello all!

I want to grab Windows desktop using DirectX. In all examples desktop is grabbed to system memory: CreateOffscreenPlainSurface with D3DPOOL_SCRATCH parameter, and then GetFrontBufferData.
But I want to grab desktop from video memory to video memory (Texture). It is because I want perform ARGB->YUV conversion using pixel shader. And only after shader I want grab result to system memory.

It is possible?
Advertisement
[font=arial, verdana, tahoma, sans-serif][size=2]I don't know if it's possible to grab the Windows desktop from video memory... (I don't think so). But what you could do is:

1. Create a texture the same size as the desktop in an initialization step[/font]
2. Capture the desktop to system memory
3. Lock the DirectX texture
4. Copy the data to the DirectX texture (watch out for the Pitch parameter of the D3DLOCKED_RECT structure)
5. Unlock the DirectX texture

Now you have your desktop in video memory and can use it for your pixel shader. I'm not sure if this helps, but I hope it does.
[font=arial, verdana, tahoma, sans-serif][size=2][font="arial, sans-serif"][size=2]I am trying to implement fastest code for Desktop capture to h.264 file. I think copy data to system memory and back is not fastest way. If direct data transfer from video memory to video memory is not possible, I will use RGBA->YUV using CPU SSE code.[/font][/font]
One thing you could do is download several open source desktop capture utilities and see how they do it. Two examples are:

http://getgreenshot.org/

http://code.google.com/p/zscreen/

This topic is closed to new replies.

Advertisement