Exemplo n.º 1
0
        public void UpdateWithPresetTest()
        {
            SmoothedData data = new SmoothedData(5);

            data.Preset(8);
            data.Update(2, 3);
            Assert.AreEqual(6, data.SmoothedValue);
        }
Exemplo n.º 2
0
        public void UpdateWithPresetDoubleWeightTest()
        {
            SmoothedData data = new SmoothedData(5);

            data.Preset(8);
            data.Update(10, 3);
            Assert.AreEqual(3, data.SmoothedValue);
        }
Exemplo n.º 3
0
        public void DefaultInitializeTest()
        {
            SmoothedData data = new SmoothedData(5);

            Assert.AreEqual(double.NaN, data.Value);
            Assert.AreEqual(5, data.SmoothPeriodS);
            Assert.AreEqual(double.NaN, data.SmoothedValue);
        }
Exemplo n.º 4
0
        public void UpdateTwoTest()
        {
            SmoothedData data = new SmoothedData(5);

            data.Update(0, 3);
            data.Update(2, 8);
            Assert.AreEqual(5, data.SmoothedValue);
        }
Exemplo n.º 5
0
        public void UpdateZeroTest()
        {
            SmoothedData data = new SmoothedData(5);

            data.Update(0, 0);
            Assert.AreEqual(0, data.Value);
            Assert.AreEqual(0, data.SmoothedValue);
        }
Exemplo n.º 6
0
        public void UpdateOneTest()
        {
            SmoothedData data = new SmoothedData(5);

            data.Update(0, 0);
            data.Update(1, 15);
            Assert.AreEqual(15, data.Value);
            Assert.AreEqual(3, data.SmoothedValue);
        }
Exemplo n.º 7
0
 public Profiler(string name)
 {
     this.name   = name;
     Wall        = new SmoothedData();
     CPU         = new SmoothedData();
     Wait        = new SmoothedData();
     timeTotal   = new Stopwatch();
     timeRunning = new Stopwatch();
     timeTotal.Start();
 }
Exemplo n.º 8
0
        public static float[] ShadowMapLimit;  // diameter of shadow map far edge from camera

        internal RenderProcess(Game game)
        {
            Game     = game;
            GameForm = (Form)Control.FromHandle(Game.Window.Handle);

            WatchdogToken = new WatchdogToken(System.Threading.Thread.CurrentThread);

            Profiler = new Profiler("Render");
            Profiler.SetThread();
            Game.SetThreadLanguage();

            Game.Window.Title     = "Open Rails";
            GraphicsDeviceManager = new GraphicsDeviceManager(game);

            var windowSizeParts = Game.Settings.WindowSize.Split(new[] { 'x' }, 2);

            GameWindowSize = new Point(Convert.ToInt32(windowSizeParts[0]), Convert.ToInt32(windowSizeParts[1]));

            FrameRate         = new SmoothedData();
            FrameTime         = new SmoothedDataWithPercentiles();
            PrimitiveCount    = new int[(int)RenderPrimitiveSequence.Sentinel];
            PrimitivePerFrame = new int[(int)RenderPrimitiveSequence.Sentinel];

            // Run the game initially at 10FPS fixed-time-step. Do not change this! It affects the loading performance.
            Game.IsFixedTimeStep   = true;
            Game.TargetElapsedTime = TimeSpan.FromMilliseconds(100);
            Game.InactiveSleepTime = TimeSpan.FromMilliseconds(100);

            // Set up the rest of the graphics according to the settings.
            GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Game.Settings.VerticalSync;
            GraphicsDeviceManager.PreferredBackBufferFormat      = SurfaceFormat.Color;
            GraphicsDeviceManager.PreferredDepthStencilFormat    = DepthFormat.Depth24Stencil8;
            GraphicsDeviceManager.IsFullScreen             = false;
            GraphicsDeviceManager.PreferMultiSampling      = Game.Settings.EnableMultisampling;
            GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(GDM_PreparingDeviceSettings);
            var screen = Game.Settings.FastFullScreenAltTab ? Screen.FromControl(GameForm) : Screen.PrimaryScreen;

            if (screen.Primary)
            {
                var wa = Screen.PrimaryScreen.WorkingArea;
                GameForm.Location = new System.Drawing.Point((wa.Right - GameWindowSize.X) / 2, (wa.Bottom - GameWindowSize.Y) / 2);
            }
            else
            {
                GameForm.Location = new System.Drawing.Point((screen.Bounds.Width - GameWindowSize.X) / 2, (screen.Bounds.Height - GameWindowSize.Y) / 2);
            }
            GameWindowOrigin = GameForm.Location;

            if (Game.Settings.FullScreen)
            {
                ToggleFullScreen();
            }

            SynchronizeGraphicsDeviceManager();
        }
Exemplo n.º 9
0
        public static float[] ShadowMapLimit;  // diameter of shadow map far edge from camera

        internal RenderProcess(Game game)
        {
            this.game = game;
            gameForm  = (Form)Control.FromHandle(game.Window.Handle);

            watchdogToken = new WatchdogToken(System.Threading.Thread.CurrentThread);

            Profiler = new Profiler("Render");
            Profiler.SetThread();
            game.SetThreadLanguage();

            game.Window.Title     = "Open Rails";
            GraphicsDeviceManager = new GraphicsDeviceManager(game);

            var windowSizeParts = game.Settings.WindowSize.Split(new[] { 'x' }, 2);

            gameWindowSize = new System.Drawing.Size(Convert.ToInt32(windowSizeParts[0]), Convert.ToInt32(windowSizeParts[1]));

            FrameRate         = new SmoothedData();
            FrameTime         = new SmoothedDataWithPercentiles();
            PrimitiveCount    = new int[(int)RenderPrimitiveSequence.Sentinel];
            PrimitivePerFrame = new int[(int)RenderPrimitiveSequence.Sentinel];

            // Run the game initially at 10FPS fixed-time-step. Do not change this! It affects the loading performance.
            game.IsFixedTimeStep   = true;
            game.TargetElapsedTime = TimeSpan.FromMilliseconds(100);
            game.InactiveSleepTime = TimeSpan.FromMilliseconds(100);

            // Set up the rest of the graphics according to the settings.
            GraphicsDeviceManager.SynchronizeWithVerticalRetrace = game.Settings.VerticalSync;
            GraphicsDeviceManager.PreferredBackBufferFormat      = SurfaceFormat.Color;
            GraphicsDeviceManager.PreferredDepthStencilFormat    = DepthFormat.Depth24Stencil8;
            GraphicsDeviceManager.IsFullScreen             = true;
            GraphicsDeviceManager.PreferMultiSampling      = game.Settings.MultisamplingCount > 0;
            GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(GDM_PreparingDeviceSettings);

            currentScreen    = Screen.PrimaryScreen;
            gameWindowOrigin = new System.Drawing.Point((currentScreen.WorkingArea.Right - gameWindowSize.Width) / 2, (currentScreen.WorkingArea.Bottom - gameWindowSize.Height) / 2);
            System.Drawing.Point tempGameWindowOrigin = gameWindowOrigin;
            SynchronizeGraphicsDeviceManager(game.Settings.FullScreen ?
                                             game.Settings.NativeFullscreenResolution ? ScreenMode.FullscreenNativeResolution : ScreenMode.FullscreenPresetResolution
                : ScreenMode.WindowedPresetResolution);

            //restore gameWindowOrigin which will be overriden when game started in Fullscreen ()
            gameWindowOrigin = tempGameWindowOrigin;

            RenderPrimitive.SetGraphicsDevice(game.GraphicsDevice);

            UserInput.Initialize(game);
            gameForm.LocationChanged += GameForm_LocationChanged;
        }
Exemplo n.º 10
0
        public Profiler(string name)
        {
            Name        = name;
            Wall        = new SmoothedData();
            CPU         = new SmoothedData();
            Wait        = new SmoothedData();
            TimeTotal   = new Stopwatch();
            TimeRunning = new Stopwatch();
            TimeTotal.Start();
#if DEBUG_THREAD_PERFORMANCE
            DebugFileStream = new StreamWriter(File.OpenWrite("debug_thread_" + name.ToLowerInvariant() + "_profiler.csv"));
            DebugFileStream.Write("Time,Event\n");
#endif
        }
Exemplo n.º 11
0
        public static float[] ShadowMapLimit;  // diameter of shadow map far edge from camera

        internal RenderProcess(Game game)
        {
            Game     = game;
            GameForm = (Form)Control.FromHandle(Game.Window.Handle);

            WatchdogToken = new WatchdogToken(System.Threading.Thread.CurrentThread);

            Profiler = new Profiler("Render");
            Profiler.SetThread();
            Game.SetThreadLanguage();

            Game.Window.Title     = "Open Rails";
            GraphicsDeviceManager = new GraphicsDeviceManager(game);

            var windowSizeParts = Game.Settings.WindowSize.Split(new[] { 'x' }, 2);

            GameWindowSize = new Point(Convert.ToInt32(windowSizeParts[0]), Convert.ToInt32(windowSizeParts[1]));

            FrameRate         = new SmoothedData();
            FrameTime         = new SmoothedDataWithPercentiles();
            PrimitiveCount    = new int[(int)RenderPrimitiveSequence.Sentinel];
            PrimitivePerFrame = new int[(int)RenderPrimitiveSequence.Sentinel];

            // Run the game initially at 10FPS fixed-time-step. Do not change this! It affects the loading performance.
            Game.IsFixedTimeStep   = true;
            Game.TargetElapsedTime = TimeSpan.FromMilliseconds(100);
            Game.InactiveSleepTime = TimeSpan.FromMilliseconds(100);

            // Set up the rest of the graphics according to the settings.
            GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Game.Settings.VerticalSync;
            GraphicsDeviceManager.PreferredBackBufferFormat      = SurfaceFormat.Color;
            GraphicsDeviceManager.PreferredDepthStencilFormat    = DepthFormat.Depth24Stencil8;
            GraphicsDeviceManager.IsFullScreen             = Game.Settings.FullScreen;
            GraphicsDeviceManager.PreferMultiSampling      = (AntiAliasingMethod)Game.Settings.AntiAliasing != AntiAliasingMethod.None;
            GraphicsDeviceManager.HardwareModeSwitch       = false; // for fast full-screen Alt-Tab switching
            GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(GDM_PreparingDeviceSettings);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Constructor. This is where it all starts.
        /// </summary>
        public TrackViewer()
        {
            graphics    = new GraphicsDeviceManager(this);
            ContentPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Content");

            Content.RootDirectory              = "Content";
            graphics.PreferredBackBufferWidth  = 1024;
            graphics.PreferredBackBufferHeight = 768;
            ScreenH = graphics.PreferredBackBufferHeight;
            ScreenW = graphics.PreferredBackBufferWidth;
            SetAliasing();
            graphics.IsFullScreen     = false;
            Window.AllowUserResizing  = true;
            Window.ClientSizeChanged += new System.EventHandler(Window_ClientSizeChanged);

            //we do not a very fast behaviour, but we do need to get all key presses
            IsFixedTimeStep   = true;
            TargetElapsedTime = TimeSpan.FromSeconds(0.05);
            FrameRate         = new SmoothedData(0.5f);
            InitLogging();

            LanguageManager = new LanguageManager();
            LanguageManager.LoadLanguage(); // need this before all menus and stuff are initialized.
        }