• Advertisement
Sign in to follow this  

Desktop capturing with DirectX 11

This topic is 757 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Dear friends,

I'm rally sorry for troubling you with this long question.Do you know any method to get the back buffer of the desktop window with DirectX 11 in C# or C++. With DirectX 9 there is a function called "GetBackBuffer". But this is too slow. When we create a window with windows programming we create a swap chain like this.

           var description = new SwapChainDescription()
                BufferCount = 1,
                Usage = Usage.RenderTargetOutput,
                OutputHandle = form.Handle,   //handle value of the window we are creating with Windows Forms
                IsWindowed = true,
                ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                SampleDescription = new SampleDescription(1, 0),
                Flags = SwapChainFlags.AllowModeSwitch,
                SwapEffect = SwapEffect.Discard

            Device device;
            SwapChain swapChain;
            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, description, out device, out     swapChain);

We can get the back buffer of this swap chain with directX 11 like this.

var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0);

But this is only the back buffer of the window we are creating. But I couldn't find a way to get the back buffer of the dekstop window with DirectX 11. I tried it by changing OutputHandle value to the desktop handle and usage to ReadOnly in swapchain description. But it didn't work. If you know some answer it will be really helpful. 
Thank you.

Edited by Ishara

Share this post

Link to post
Share on other sites

The problem I think is that you can't simply access the desktop backbuffer (there might not even be one -> classic theme) from DirectX. You best bet is probably using GDI. It's not that performant, but you only need to grab it once:


Look at http://stackoverflow.com/questions/5069104/fastest-method-of-screen-capturing, the GID way.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement