Esempio n. 1
0
        /// <summary>
        /// Hooked to allow resizing a texture/surface that is reused. Currently not in use as we create the texture for each request
        /// to support different sizes each time (as we use DirectX to copy only the region we are after rather than the entire backbuffer)
        /// </summary>
        /// <param name="swapChainPtr"></param>
        /// <param name="newTargetParameters"></param>
        /// <returns></returns>
        int ResizeTargetHook(IntPtr swapChainPtr, ref DXGI.DXGI_MODE_DESC newTargetParameters)
        {
            using (SlimDX.DXGI.SwapChain swapChain = SlimDX.DXGI.SwapChain.FromPointer(swapChainPtr))
            {
                // This version creates a new texture for each request so there is nothing to resize.
                // IF the size of the texture is known each time, we could create it once, and then possibly need to resize it here

                if (bitmap != null)
                {
                    bitmap.Dispose();
                    bitmap = null;
                }
                return(swapChain.ResizeTarget(
                           new SlimDX.DXGI.ModeDescription()
                {
                    Format = newTargetParameters.Format,
                    Height = newTargetParameters.Height,
                    RefreshRate = newTargetParameters.RefreshRate,
                    Scaling = newTargetParameters.Scaling,
                    ScanlineOrdering = newTargetParameters.ScanlineOrdering,
                    Width = newTargetParameters.Width
                }
                           ).Code);
            }
        }
 /// <summary>
 /// Toggles the swap chain to full screen mode.
 /// </summary>
 public override void ToggleFullScreen()
 {
     _resetting              = true;
     _isFullScreen           = !_isFullScreen;
     _swapChain.IsFullScreen = _isFullScreen;
     //Resize targets
     if (_isFullScreen)
     {
         DXGI.ModeDescription modeDesc = new DXGI.ModeDescription();
         modeDesc.Format      = D3D10Helper.ToD3DSurfaceFormat(_presentParams.BackBufferFormat);
         modeDesc.Width       = _presentParams.BackBufferWidth;
         modeDesc.Height      = _presentParams.BackBufferHeight;
         modeDesc.RefreshRate = new SDX.Rational(0, 0);
         _swapChain.ResizeTarget(modeDesc);
     }
     _resetting = false;
 }