Пример #1
0
 public override void ChangedWorldConfig(GraphicsDevice gd)
 {
     base.ChangedWorldConfig(gd);
     PPXDepthEngine.SSAA = (WorldConfig.Current.AA ? 2 : 1);
     PPXDepthEngine.InitScreenTargets();
     UseBackbuffer = WorldConfig.Current.AA;
 }
Пример #2
0
        /// <summary>
        /// Setup anything that needs a GraphicsDevice
        /// </summary>
        /// <param name="layer"></param>
        public override void Initialize(_3DLayer layer)
        {
            base.Initialize(layer);

            /**
             * Setup world state, this object acts as a facade
             * to world objects as well as providing various
             * state settings for the world and helper functions
             */
            State = new WorldState(layer.Device, layer.Device.Viewport.Width / FSOEnvironment.DPIScaleFactor, layer.Device.Viewport.Height / FSOEnvironment.DPIScaleFactor, this);

            State._3D = new FSO.LotView.Utils._3DWorldBatch(State);
            State._2D = new FSO.LotView.Utils._2DWorldBatch(layer.Device, World2D.NUM_2D_BUFFERS,
                                                            World2D.BUFFER_SURFACE_FORMATS, World2D.FORMAT_ALWAYS_DEPTHSTENCIL, World2D.SCROLL_BUFFER);

            ChangedWorldConfig(layer.Device);

            PPXDepthEngine.InitGD(layer.Device);
            PPXDepthEngine.InitScreenTargets();

            base.Camera = State.Camera;

            HasInitGPU = true;
            HasInit    = HasInitGPU & HasInitBlueprint;
        }
Пример #3
0
        /// <summary>
        /// Setup anything that needs a GraphicsDevice
        /// </summary>
        /// <param name="layer"></param>
        public override void Initialize(_3DLayer layer)
        {
            base.Initialize(layer);

            /**
             * Setup world state, this object acts as a facade
             * to world objects as well as providing various
             * state settings for the world and helper functions
             */
            State = new WorldState(layer.Device, layer.Device.Viewport.Width, layer.Device.Viewport.Height, this);

            State._2D = new _2DWorldBatch(layer.Device, _2DWorldBatch.NUM_2D_BUFFERS,
                                          _2DWorldBatch.BUFFER_SURFACE_FORMATS, _2DWorldBatch.FORMAT_ALWAYS_DEPTHSTENCIL, _2DWorldBatch.SCROLL_BUFFER);

            Static = new WorldStatic(this);

            State.OutsidePx = new Texture2D(layer.Device, 1, 1);

            ChangedWorldConfig(layer.Device);

            PPXDepthEngine.InitGD(layer.Device);
            PPXDepthEngine.InitScreenTargets();

            base.Camera = State.Camera;

            HasInitGPU = true;
            HasInit    = HasInitGPU & HasInitBlueprint;
            GraphicsModeControl.ModeChanged += SetGraphicsMode;
        }
Пример #4
0
        public void ChangeAAMode(GraphicsDevice gd)
        {
            var lastm = PPXDepthEngine.MSAA;
            var lasts = PPXDepthEngine.SSAA;

            PPXDepthEngine.SSAAFunc = SSAADownsample.Draw;
            switch (WorldConfig.Current.AA)
            {
            case 0:
                PPXDepthEngine.MSAA = 0;
                PPXDepthEngine.SSAA = 1;
                break;

            case 1:
                PPXDepthEngine.MSAA = 4;
                PPXDepthEngine.SSAA = 1;
                break;

            case 2:
                PPXDepthEngine.MSAA = 0;
                PPXDepthEngine.SSAA = 2;
                break;
            }

            if (PPXDepthEngine.SSAA > 1 && State.CameraMode < CameraRenderMode._3D)
            {
                PPXDepthEngine.MSAA = 8;
                PPXDepthEngine.SSAA = 1;
            }
            if (lastm != PPXDepthEngine.MSAA || lasts != PPXDepthEngine.SSAA)
            {
                PPXDepthEngine.InitScreenTargets();
            }
        }
Пример #5
0
        public void GameResized()
        {
            PPXDepthEngine.InitScreenTargets();
            var newSize = PPXDepthEngine.GetWidthHeight();

            State._2D.GenBuffers(newSize.X, newSize.Y);
            State.SetDimensions(newSize.ToVector2());

            Blueprint?.Damage.Add(new BlueprintDamage(BlueprintDamageType.ZOOM));
        }
Пример #6
0
        public void GameResized()
        {
            PPXDepthEngine.InitScreenTargets();
            var newSize = PPXDepthEngine.GetWidthHeight();
            var ssaa    = new Point(newSize.X / PPXDepthEngine.SSAA, newSize.Y / PPXDepthEngine.SSAA);

            State._2D.GenBuffers(ssaa.X, ssaa.Y);
            State.SetDimensions(ssaa.ToVector2());

            Blueprint?.Changes?.SetFlag(BlueprintGlobalChanges.ZOOM);
        }
Пример #7
0
        public override void ChangedWorldConfig(GraphicsDevice gd)
        {
            base.ChangedWorldConfig(gd);
            switch (WorldConfig.Current.AA)
            {
            case 1:
                PPXDepthEngine.MSAA = 4;
                PPXDepthEngine.SSAA = 1;
                break;

            case 2:
                PPXDepthEngine.SSAA = 2;
                PPXDepthEngine.MSAA = 0;
                break;

            default:
                PPXDepthEngine.MSAA = 0;
                PPXDepthEngine.SSAA = 1;
                break;
            }
            PPXDepthEngine.InitScreenTargets();
            UseBackbuffer = WorldConfig.Current.AA > 0;
        }
Пример #8
0
        public virtual void ChangedWorldConfig(GraphicsDevice gd)
        {
            //destroy any features that are no longer enabled.

            var config = WorldConfig.Current;

            if (ForceAdvLight)
            {
                config.LightingMode = Math.Max(config.LightingMode, 1);
            }

            if (config.AdvancedLighting)
            {
                State.AmbientLight?.Dispose();
                State.AmbientLight = null;
                Light?.Dispose();
                Light = null;
                if (Light == null)
                {
                    Light = new LMapBatch(gd, 8);
                    if (Blueprint != null)
                    {
                        Light?.Init(Blueprint);
                        Blueprint.Damage.Add(new BlueprintDamage(BlueprintDamageType.ROOM_CHANGED));
                        Blueprint.Damage.Add(new BlueprintDamage(BlueprintDamageType.OUTDOORS_LIGHTING_CHANGED));
                    }
                    State.Light = Light;
                }
            }
            else
            {
                Light?.Dispose();
                Light       = null;
                State.Light = null;
                if (State.AmbientLight == null)
                {
                    State.AmbientLight = new Texture2D(gd, 256, 256);
                }
                if (Blueprint != null)
                {
                    Blueprint.Damage.Add(new BlueprintDamage(BlueprintDamageType.OUTDOORS_LIGHTING_CHANGED));
                }
            }

            if (Blueprint != null && !FSOEnvironment.Enable3D)
            {
                var shad3D = (Blueprint.WCRC != null);
                if (config.Shadow3D != shad3D)
                {
                    if (config.AdvancedLighting && config.Shadow3D)
                    {
                        Blueprint.WCRC           = new RC.WallComponentRC();
                        Blueprint.WCRC.blueprint = Blueprint;
                        Blueprint.WCRC.Generate(gd, State, false);
                    }
                    else
                    {
                        Blueprint.WCRC?.Dispose();
                        Blueprint.WCRC = null;
                    }
                    Blueprint.Damage.Add(new BlueprintDamage(BlueprintDamageType.OUTDOORS_LIGHTING_CHANGED));
                }
            }

            if (!FSOEnvironment.Enable3D)
            {
                var last = PPXDepthEngine.MSAA;
                PPXDepthEngine.MSAA = (WorldConfig.Current.AA ? 4 : 0);
                if (last != PPXDepthEngine.MSAA)
                {
                    PPXDepthEngine.InitScreenTargets();
                }
            }
        }