/// <summary>
        /// Re-calculates the scaling of the rendered screen to fill the window.
        /// </summary>
        private void RecalculateScaling()
        {
            double xRatio = (WindowWidth) / (double)RenderResolutionX;
            double yRatio = (WindowHeight) / (double)RenderResolutionY;

            double ratio;

            int texturePositionX = 0;
            int texturePositionY = 0;
            int textureHeight    = 0;
            int textureWidth     = 0;

            if (xRatio > yRatio)
            {
                ratio            = yRatio;
                textureHeight    = WindowHeight;
                textureWidth     = (int)(RenderResolutionX * ratio);
                texturePositionX = (int)(WindowWidth - textureWidth) / 2;
            }
            else
            {
                ratio            = xRatio;
                textureWidth     = WindowWidth;
                textureHeight    = (int)(RenderResolutionY * ratio);
                texturePositionY = (int)(WindowHeight - textureHeight) / 2;
            }

            ScaleRatio     = ratio;
            SceneXPosition = texturePositionX;
            SceneYPosition = texturePositionY;

            if (renderTarget != null && !renderTarget.IsDisposed)
            {
                renderTarget.Dispose();
            }

            if (doubledRenderTarget != null && !doubledRenderTarget.IsDisposed)
            {
                doubledRenderTarget.Dispose();
            }

            renderTarget = new RenderTarget2D(GraphicsDevice, RenderResolutionX, RenderResolutionY, false, SurfaceFormat.Color,
                                              DepthFormat.None, 0, RenderTargetUsage.PreserveContents);

            RenderTargetStack.Initialize(renderTarget, GraphicsDevice);

            if (ScaleRatio > 1.5)
            {
                // Enable sharper scaling method
                doubledRenderTarget = new RenderTarget2D(GraphicsDevice,
                                                         RenderResolutionX * 2, RenderResolutionY * 2, false, SurfaceFormat.Color,
                                                         DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
            }
            else
            {
                doubledRenderTarget = null;
            }
        }
 public static void PopRenderTarget() => RenderTargetStack.PopRenderTarget();
 public static void PushRenderTarget(RenderTarget2D renderTarget) => RenderTargetStack.PushRenderTarget(renderTarget);