Sign in to follow this  
physic

Capture desktop to Texture

Recommended Posts

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?

Share this post


Link to post
Share on other sites
[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[/size][/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.

Share this post


Link to post
Share on other sites
[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.[/size][/font][/size][/font]

Share this post


Link to post
Share on other sites
One thing you could do is download several open source desktop capture utilities and see how they do it. Two examples are:

[url="http://getgreenshot.org/"]http://getgreenshot.org/[/url]

[url="http://code.google.com/p/zscreen/"]http://code.google.com/p/zscreen/[/url]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this