Ejemplo n.º 1
0
        public MainMenuRenderSetup()
        {
            // Shaders
            lastResizeMode = Settings.Resize;

            try {
                switch (lastResizeMode)
                {
                default:
                case Settings.ResizeMode.None:
                    resizeShader = DrawTechnique.Solid;
                    break;

                case Settings.ResizeMode.HQ2x:
                    resizeShader = ContentResolver.Current.RequestShader("ResizeHQ2x");
                    break;

                case Settings.ResizeMode.xBRZ3:
                    resizeShader = ContentResolver.Current.RequestShader("Resize3xBRZ");
                    break;

                case Settings.ResizeMode.xBRZ4:
                    resizeShader = ContentResolver.Current.RequestShader("Resize4xBRZ");
                    break;

                case Settings.ResizeMode.CRT:
                    resizeShader = ContentResolver.Current.RequestShader("ResizeCRT");
                    break;
                }
            } catch {
                resizeShader = DrawTechnique.Solid;
            }

            // Textures
            finalTexture = new Texture(null, TextureSizeMode.NonPowerOfTwo, TextureMagFilter.Nearest, TextureMinFilter.Nearest);

            finalTarget = new RenderTarget(AAQuality.Off, false, finalTexture);

            // Render steps
            AddRenderStep(RenderStepPosition.Last, new RenderStep {
                MatrixMode     = RenderMatrix.ScreenSpace,
                VisibilityMask = VisibilityFlag.All,
                ClearFlags     = ClearFlag.None,

                Output = finalTarget
            });

            AddRenderStep(RenderStepPosition.Last, new RenderStep {
                Id = "Resize",

                MatrixMode     = RenderMatrix.ScreenSpace,
                VisibilityMask = VisibilityFlag.None
            });
        }
Ejemplo n.º 2
0
        protected override void OnRenderPointOfView(Scene scene, DrawDevice drawDevice, Rect viewportRect, Vector2 imageSize)
        {
            // Switch between resize modes if necessary
            if (lastResizeMode != Settings.Resize)
            {
                lastResizeMode = Settings.Resize;

                try {
                    switch (lastResizeMode)
                    {
                    default:
                    case Settings.ResizeMode.None:
                        resizeShader = DrawTechnique.Solid;
                        break;

                    case Settings.ResizeMode.HQ2x:
                        resizeShader = ContentResolver.Current.RequestShader("ResizeHQ2x");
                        break;

                    case Settings.ResizeMode.xBRZ3:
                        resizeShader = ContentResolver.Current.RequestShader("Resize3xBRZ");
                        break;

                    case Settings.ResizeMode.xBRZ4:
                        resizeShader = ContentResolver.Current.RequestShader("Resize4xBRZ");
                        break;

                    case Settings.ResizeMode.CRT:
                        resizeShader = ContentResolver.Current.RequestShader("ResizeCRT");
                        break;
                    }
                } catch {
                    resizeShader = DrawTechnique.Solid;
                }
            }

            // Check if resolution changed
            if (lastImageSize != imageSize)
            {
                lastImageSize = imageSize;

                const float defaultRatio = (float)defaultWidth / defaultHeight;
                float       currentRatio = imageSize.X / imageSize.Y;

                int width, height;
                if (currentRatio > defaultRatio)
                {
                    width  = MathF.Min(defaultWidth, (int)imageSize.X);
                    height = (int)(width / currentRatio);
                }
                else if (currentRatio < defaultRatio)
                {
                    height = MathF.Min(defaultHeight, (int)imageSize.Y);
                    width  = (int)(height * currentRatio);
                }
                else
                {
                    width  = MathF.Min(defaultWidth, (int)imageSize.X);
                    height = MathF.Min(defaultHeight, (int)imageSize.Y);
                }

                TargetSize = new Point2(width, height);

                ResizeRenderTarget(finalTarget, TargetSize);
            }

            base.OnRenderPointOfView(scene, drawDevice, viewportRect, imageSize);
        }