public void UpdateWithPresetDoubleWeightTest() { SmoothedDataWithPercentiles data = new SmoothedDataWithPercentiles(); data.Preset(8); data.Update(5, 3); Assert.AreEqual(3, data.SmoothedValue); }
public void UpdateTest() { SmoothedDataWithPercentiles data = new SmoothedDataWithPercentiles(); data.Update(2, 3); data.Update(2, 6); data.Update(2, 2); Assert.AreEqual(3, data.SmoothedValue); }
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(); }
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; }
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); }