void Setup()
        {
            Scene = new Scene();
            GameState = GameState.Playing;
            InterfaceIngameScene = new Scene();
            Scene.View = InterfaceIngameScene.View = Program.Instance;
            Scene.Camera = InterfaceIngameScene.Camera = new LookatSphericalCamera()
            {
                Lookat = new Vector3(0, 0, 0),
                Position = new Vector3(10, 10, 10),
                FOV = Program.Settings.CameraFOV,
                ZFar = 20,
                ZNear = Program.Settings.CameraZNear,
                AspectRatio = Program.Instance.AspectRatio
            };
            CameraController = new CameraController { Camera = (LookatSphericalCamera)Scene.Camera };
            Scene.EntityAdded += scene_EntityAdded;

            Program.Instance.Interface.Layer1.AddChild(
                SceneControl = new GameSceneControl
                {
                    InnerScene = Scene,
                    Size = Program.Instance.Interface.Size
                });

            InterfaceIngameRenderer = new Graphics.Interface.InterfaceRenderer9(Program.Instance.Device9)
            {
                Scene = InterfaceIngameScene,
                StateManager = Program.Instance.StateManager,
            };
            InterfaceIngameRenderer.Initialize(Scene.View);

            if (Program.Settings.OutputPNGSequence)
                Directory.CreateDirectory(OutputPNGSequencePath);

            if (Program.Settings.UseDummyRenderer)
            {
                throw new NotSupportedException("Dummy renderer is no longer supported.");
            }
            else
            {
                Renderer = new Graphics.Renderer.Renderer(Program.Instance.Device9)
                {
                    Scene = Scene,
                    StateManager = Program.Instance.StateManager,
                    Settings = Program.Settings.RendererSettings,
                };
                SceneRendererConnector = new SortedTestSceneRendererConnector
                {
                    Scene = Scene,
                    Renderer = Renderer
                };
            }

            Graphics.Renderer.Results result = Renderer.Initialize(Scene.View);
            SceneRendererConnector.Initialize();
            if (result == Graphics.Renderer.Results.OutOfVideoMemory)
            {
                System.Windows.Forms.MessageBox.Show(Locale.Resource.ErrorOutOfVideoMemory);
                Application.Log("User ran out of video memory according to renderer. This is probably due to having too high shadow quality.");
                System.Windows.Forms.Application.Exit();
            }

            RendererSettingsController = new RendererSettingsController();

            var s = Program.Settings.GraphicsDeviceSettings.Resolution;
            Program.Instance.Interface.Layer1.AddChild(Interface = new Interface.Interface
            {
                Size = new Vector2(s.Width, s.Height),
                Visible = false
            });
        }
Beispiel #2
0
        void Setup()
        {
            Scene                = new Scene();
            GameState            = GameState.Playing;
            InterfaceIngameScene = new Scene();
            Scene.View           = InterfaceIngameScene.View = Program.Instance;
            Scene.Camera         = InterfaceIngameScene.Camera = new LookatSphericalCamera()
            {
                Lookat      = new Vector3(0, 0, 0),
                Position    = new Vector3(10, 10, 10),
                FOV         = Program.Settings.CameraFOV,
                ZFar        = 20,
                ZNear       = Program.Settings.CameraZNear,
                AspectRatio = Program.Instance.AspectRatio
            };
            CameraController = new CameraController {
                Camera = (LookatSphericalCamera)Scene.Camera
            };
            Scene.EntityAdded += scene_EntityAdded;

            Program.Instance.Interface.Layer1.AddChild(
                SceneControl = new GameSceneControl
            {
                InnerScene = Scene,
                Size       = Program.Instance.Interface.Size
            });

            InterfaceIngameRenderer = new Graphics.Interface.InterfaceRenderer9(Program.Instance.Device9)
            {
                Scene        = InterfaceIngameScene,
                StateManager = Program.Instance.StateManager,
            };
            InterfaceIngameRenderer.Initialize(Scene.View);

            if (Program.Settings.OutputPNGSequence)
            {
                Directory.CreateDirectory(OutputPNGSequencePath);
            }

            if (Program.Settings.UseDummyRenderer)
            {
                throw new NotSupportedException("Dummy renderer is no longer supported.");
            }
            else
            {
                Renderer = new Graphics.Renderer.Renderer(Program.Instance.Device9)
                {
                    Scene        = Scene,
                    StateManager = Program.Instance.StateManager,
                    Settings     = Program.Settings.RendererSettings,
                };
                SceneRendererConnector = new SortedTestSceneRendererConnector
                {
                    Scene    = Scene,
                    Renderer = Renderer
                };
            }

            Graphics.Renderer.Results result = Renderer.Initialize(Scene.View);
            SceneRendererConnector.Initialize();
            if (result == Graphics.Renderer.Results.OutOfVideoMemory)
            {
                System.Windows.Forms.MessageBox.Show(Locale.Resource.ErrorOutOfVideoMemory);
                Application.Log("User ran out of video memory according to renderer. This is probably due to having too high shadow quality.");
                System.Windows.Forms.Application.Exit();
            }

            RendererSettingsController = new RendererSettingsController();

            var s = Program.Settings.GraphicsDeviceSettings.Resolution;

            Program.Instance.Interface.Layer1.AddChild(Interface = new Interface.Interface
            {
                Size    = new Vector2(s.Width, s.Height),
                Visible = false
            });
        }