Beispiel #1
0
        private void RefreshDXWindow()
        {
            if (_chain != null)
            {
                _chain.Dispose();
                _chain = new SwapChainRenderTarget(_graphicsDeviceService.GraphicsDevice, Handle, ClientSize.Width,
                                                   ClientSize.Height);

                GraphicsDevice.PresentationParameters.BackBufferWidth  = ClientSize.Width;
                GraphicsDevice.PresentationParameters.BackBufferHeight = ClientSize.Height;

                SwapChainRenderTargetRefreshed?.Invoke(_chain);
            }
        }
Beispiel #2
0
        protected override void Dispose(bool disposing)
        {
            if (graphicsDeviceService != null)
            {
                graphicsDeviceService.Release(disposing);
                graphicsDeviceService = null;
            }

            if (_renderTarget != null)
            {
                _renderTarget.Dispose();
                _renderTarget = null;
            }

            base.Dispose(disposing);
        }
        private void CreateSwapChain()
        {
            if (!Globals.ClosingEditor)
            {
                if (mChain != null)
                {
                    mChain.Dispose();
                }

                if (Graphics.GetGraphicsDevice() != null)
                {
                    if (pnlMapGrid.Width > 0 && pnlMapGrid.Height > 0)
                    {
                        if (pnlMapGrid.Width > 0 && pnlMapGrid.Height > 0)
                        {
                            mChain = new SwapChainRenderTarget(
                                Graphics.GetGraphicsDevice(), pnlMapGrid.Handle, pnlMapGrid.Width, pnlMapGrid.Height,
                                false, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.DiscardContents,
                                PresentInterval.Immediate
                                );

                            Graphics.SetMapGridChain(mChain);
                        }
                    }
                }
            }
        }
Beispiel #4
0
 public virtual void SetWindowSize(int width, int height)
 {
     //if window size doesn't match, resize it and create new render target of proper size
     if (width > 0 && height > 0)
     {
         if (SwapChain == null || width != SwapChain.Bounds.Width || height != SwapChain.Bounds.Height)
         {
             Form.ClientSize = new System.Drawing.Size(width, height);
             SwapChain?.Dispose();
             SwapChain = new SwapChainRenderTarget(GraphicsDevice, Window.Handle, width, height);
             ResizeRecursive(new Rectangle(0, 0, width, height));
         }
     }
 }
Beispiel #5
0
 private void CreateSwapChain()
 {
     if (_chain != null)
     {
         _chain.Dispose();
     }
     if (_graphicsDevice != null)
     {
         if (this.Width > 0 && this.Height > 0)
         {
             _chain = new SwapChainRenderTarget(_graphicsDevice,
                                                this.Handle,
                                                this.Width, this.Height, false, SurfaceFormat.Color,
                                                DepthFormat.Depth24, 0, RenderTargetUsage.DiscardContents, PresentInterval.Immediate);
         }
     }
 }
        protected override void OnClientSizeChanged(EventArgs e)
        {
            base.OnClientSizeChanged(e);

            if (_chain != null)
            {
                if (ClientSize.Width > 0 && ClientSize.Height > 0)
                {
                    _chain.Dispose();
                    _chain = new SwapChainRenderTarget(_graphicsDeviceService.GraphicsDevice, Handle, ClientSize.Width,
                                                       ClientSize.Height);

                    GraphicsDevice.PresentationParameters.BackBufferWidth  = ClientSize.Width;
                    GraphicsDevice.PresentationParameters.BackBufferHeight = ClientSize.Height;

                    SwapChainRenderTargetRefreshed?.Invoke(_chain);
                }
            }
        }