• Advertisement
Sign in to follow this  

Desktop capturing with DirectX 11

This topic is 819 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
Advertisement
Yes dxgi works on all directx from 10 and up iirc, which means you can use it on anything newer than windows xp.

Share this post


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

  • Advertisement