public override void WindowMovedOrResized() { if ( GetForm( hWnd ) == null || GetForm( hWnd ).WindowState == SWF.FormWindowState.Minimized ) { return; } // top and left represent outer window position top = hWnd.Top; left = hWnd.Left; // width and height represent drawable area only int width = hWnd.ClientRectangle.Width; int height = hWnd.ClientRectangle.Height; LogManager.Instance.Write( "[D3D] RenderWindow Resized - new dimensions L:{0},T:{1},W:{2},H:{3}", hWnd.Left, hWnd.Top, hWnd.ClientRectangle.Width, hWnd.ClientRectangle.Height ); if ( Width == width && Height == height ) { return; } if ( _isSwapChain ) { D3D.PresentParameters pp = _d3dpp; pp.BackBufferWidth = width; pp.BackBufferHeight = height; _swapChain.Dispose(); _swapChain = null; try { _swapChain = new D3D.SwapChain( D3DDevice, pp ); _d3dpp = pp; this.width = width; this.height = height; } catch ( Exception ) { LogManager.Instance.Write( "Failed to reset device to new dimensions {0}x{1}. Trying to recover.", width, height ); try { _swapChain = new D3D.SwapChain( D3DDevice, _d3dpp ); } catch ( Exception ex ) { throw new Exception( "Reset window to last size failed.", ex ); } } } else // primary windows must reset the device { _d3dpp.BackBufferWidth = this.width = width; _d3dpp.BackBufferHeight = this.height = height; } // Notify viewports of resize foreach ( Viewport entry in this.ViewportList.Values ) { //entry.UpdateDimensions(); } }
public void DisposeD3DResources() { // Dispose D3D Resources if ( _isSwapChain ) { _swapChain.Dispose(); _swapChain = null; } }