Exemplo n.º 1
0
        public static DX11SwapChain FromHandle(DxDevice device, IntPtr handle, Format format, SampleDescription sampledesc)
        {
            DX11SwapChain swapShain = new DX11SwapChain();

            swapShain.device = device;

            SwapChainDescription sd = new SwapChainDescription()
            {
                BufferCount       = 2,
                ModeDescription   = new ModeDescription(0, 0, new Rational(60, 1), format),
                IsWindowed        = true,
                OutputHandle      = handle,
                SampleDescription = sampledesc,
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput | Usage.ShaderInput,
                Flags             = SwapChainFlags.None
            };

            if (device.IsFeatureLevel11 && sampledesc.Count == 1)
            {
                sd.Usage |= Usage.UnorderedAccess;
            }
            swapShain.swapchain = new SwapChain(device.Factory, device.Device, sd);
            swapShain.Initialize();
            return(swapShain);
        }
Exemplo n.º 2
0
        public static DX11SwapChain FlipSequential(DxDevice device, IntPtr handle, Format format, Rational refreshRate)
        {
            DX11SwapChain swapShain = new DX11SwapChain();

            swapShain.device = device;

            SwapChainDescription sd = new SwapChainDescription()
            {
                BufferCount       = 2,
                ModeDescription   = new ModeDescription(0, 0, refreshRate, format),
                IsWindowed        = true,
                OutputHandle      = handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.FlipSequential,
                Usage             = Usage.RenderTargetOutput,
                Flags             = SwapChainFlags.None
            };

            swapShain.swapchain = new SwapChain(device.Factory, device.Device, sd);
            swapShain.Initialize();
            return(swapShain);
        }
Exemplo n.º 3
0
        public static DX11SwapChain FromComposition(DxDevice dxDevice, int w, int h)
        {
            DX11SwapChain swapShain = new DX11SwapChain();

            swapShain.device = dxDevice;
            var desc = new SharpDX.DXGI.SwapChainDescription1()
            {
                Width             = w,
                Height            = h,
                Format            = SharpDX.DXGI.Format.B8G8R8A8_UNorm,
                Stereo            = false,
                SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
                Usage             = SharpDX.DXGI.Usage.BackBuffer | SharpDX.DXGI.Usage.RenderTargetOutput | Usage.ShaderInput,
                BufferCount       = 2,
                Scaling           = SharpDX.DXGI.Scaling.None,
                SwapEffect        = SharpDX.DXGI.SwapEffect.FlipSequential,
                AlphaMode         = AlphaMode.Premultiplied
            };

            swapShain.swapchain = new SwapChain1(dxDevice.Factory, dxDevice.Device, ref desc);
            swapShain.Initialize();
            return(swapShain);
        }
Exemplo n.º 4
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            Device device = context.Device;

            if (this.updateddevices.Contains(context)) { return; }

            SampleDescription sd = new SampleDescription(1, 0);

            if (this.FResized || this.FInvalidateSwapChain || this.swapchain == null)
            {
                if (this.swapchain != null) { this.swapchain.Dispose(); }
                this.swapchain = new DX11SwapChain(context, this.form.Handle, Format.R8G8B8A8_UNorm, sd,this.FInRate[0],1);
            }

            if (this.renderer == null) { this.renderer = new DX11GraphicsRenderer(this.FHost, context); }
            this.updateddevices.Add(context);

            if (this.FInFullScreen[0] != this.swapchain.IsFullScreen)
            {
                if (this.FInFullScreen[0])
                {
                    this.prevx = this.form.Width;
                    this.prevy = this.form.Height;

                    /*Screen screen = Screen.FromControl(this.form);*/
                    this.form.FormBorderStyle = FormBorderStyle.None;
                    this.form.Width = Convert.ToInt32(this.FInRes[0].X);
                    this.form.Height = Convert.ToInt32(this.FInRes[0].Y);

                    this.swapchain.Resize();

                    this.swapchain.SetFullScreen(true);

                    this.setfull = false;
                }
                else
                {
                    this.swapchain.SetFullScreen(false);
                    this.form.FormBorderStyle = FormBorderStyle.Fixed3D;
                    this.form.Width = this.prevx;
                    this.form.Height = this.prevy;
                    this.swapchain.Resize();

                }
            }
        }
 private void CreateSwapChain()
 {
     if (this.swapChain == null && this.RenderContext != null)
     {
         this.swapChain = new DX11SwapChain(this.RenderContext, this.node.Window.Handle, SlimDX.DXGI.Format.R8G8B8A8_UNorm, new SlimDX.DXGI.SampleDescription(1, 0), 60, 2);
         this.RenderContext.Factory.SetWindowAssociation(this.node.Window.Handle, SlimDX.DXGI.WindowAssociationFlags.IgnoreAll);
     }
 }
 private void CreateSwapChain()
 {
     if (this.swapChain == null && this.RenderContext != null)
     {
         NativeWindow nativeWindow = new NativeWindow();
         nativeWindow.AssignHandle(this.node.Window.Handle);
         this.form.Show(nativeWindow);//   IWin32Window ^ w = Control::FromHandle(myWindowHandle);
         this.form.FormBorderStyle = FormBorderStyle.None;
         this.form.Left = 1920;
         this.form.Top = 0;
         this.form.Width = 1920;
         this.form.Height = 1080;
         this.swapChain = new DX11SwapChain(this.RenderContext, this.form.Handle, SlimDX.DXGI.Format.R8G8B8A8_UNorm, new SlimDX.DXGI.SampleDescription(1, 0), 60, 2);
         this.RenderContext.Factory.SetWindowAssociation(this.form.Handle, SlimDX.DXGI.WindowAssociationFlags.IgnoreAll);
     }
 }