static void Main(string[] args) { //BitmapFont someFont = new BitmapFont("arial.ttf"); //Console.ReadKey(); ConfigReader.Read("config.txt"); DisplayDevice device = DisplayDevice.GetDisplay((DisplayIndex)GameWindowSettings.displayID); if (GameWindowSettings.width == 0) { GameWindowSettings.width = device.Width; } if (GameWindowSettings.height == 0) { GameWindowSettings.height = device.Height; } Debug.WriteLine("Using gfx device: " + device.ToString()); InkubusCore core = new InkubusCore((GameWindowSettings.fullscreen) ? 0 : (device.Width / 2 - GameWindowSettings.width / 2), (GameWindowSettings.fullscreen) ? 0 : (device.Height / 2 - GameWindowSettings.height / 2), GameWindowSettings.width, GameWindowSettings.height, GraphicsMode.Default, GameWindowSettings.fullscreen ? GameWindowFlags.Fullscreen : GameWindowFlags.FixedWindow, device); }
private static DisplayDevice findDisplayDevice() { try { // Can throw ArgumentOutOfRangeException with OpenTK.Platform.SDL2 return(DisplayDevice.GetDisplay(DisplayIndex.Default)); } catch (Exception e1) { Trace.WriteLine($"Failed to use the default display device: {e1}"); var deviceIndex = 0; while (deviceIndex <= (int)DisplayIndex.Sixth) { try { return(DisplayDevice.GetDisplay((DisplayIndex)deviceIndex)); } catch (Exception e2) { Trace.WriteLine($"Failed to use display device #{deviceIndex}: {e2}"); deviceIndex++; } } } throw new InvalidOperationException("Failed to find a display device"); }
private void UpdateWindowKeys(KeyboardState keyboard) { if (keyboard.IsKeyDown(Key.Escape)) { Exit(); } if (keyboard[Key.F11] && (lastKeyboard[Key.F11] != keyboard[Key.F11])) { DisplayDevice defaultDisplayDevice = DisplayDevice.GetDisplay(DisplayIndex.Default); if (WindowState == WindowState.Fullscreen) { WindowState = WindowState.Normal; CursorVisible = true; defaultDisplayDevice.RestoreResolution(); } else { WindowState = WindowState.Fullscreen; CursorVisible = false; defaultDisplayDevice .ChangeResolution( Const.DISPLAY_FULLHD_W, Const.DISPLAY_FULLHD_H, Const.DISPLAY_BITPERPIXEL, Const.DISPLAY_REFRESH_RATE); } } // if state F11 } // UpdateWindowKeys()
public static void LogDisplayDevices() { Log.Core.Write("Available display devices:"); Log.Core.PushIndent(); foreach (DisplayIndex index in new[] { DisplayIndex.First, DisplayIndex.Second, DisplayIndex.Third, DisplayIndex.Fourth, DisplayIndex.Sixth }) { DisplayDevice display = DisplayDevice.GetDisplay(index); if (display == null) { continue; } Log.Core.Write( "{0,-6}: {1,4}x{2,4} at {3,3} Hz, {4,2} bpp, pos [{5,4},{6,4}]{7}", index, display.Width, display.Height, display.RefreshRate, display.BitsPerPixel, display.Bounds.X, display.Bounds.Y, display.IsPrimary ? " (Primary)" : ""); } Log.Core.PopIndent(); }
private void refreshScreens() { screenContainer.Remove(windowContainer); screenContainer.Clear(); var bounds = new RectangleI(); for (int i = 0;; i++) { var device = DisplayDevice.GetDisplay((DisplayIndex)i); if (device == null) { break; } screenContainer.Add(createScreen(device, device.IsPrimary ? $"Screen {i} (Primary)" : $"Screen {i}")); bounds = RectangleI.Union(bounds, new RectangleI(device.Bounds.X, device.Bounds.Y, device.Width, device.Height)); } screenContainer.Add(windowContainer); screenContainerOffset = bounds.Location; foreach (var box in screenContainer.Children) { box.Position -= bounds.Location; } screenContainer.Size = bounds.Size; }
private void UpdateWindowState() { if (!this.updateClientBounds) { return; } this.updateClientBounds = false; if (this.windowState == WindowState.Normal && this.window.WindowState == WindowState.Maximized || this.windowState == WindowState.Maximized && this.window.WindowState == WindowState.Normal) { this.windowState = this.window.WindowState; } else { this.window.WindowState = this.windowState; } WindowBorder windowBorder = !this._isBorderless ? (this._isResizable ? WindowBorder.Resizable : WindowBorder.Fixed) : WindowBorder.Hidden; if (windowBorder != this.window.WindowBorder && this.window.WindowState != WindowState.Fullscreen) { this.window.WindowBorder = windowBorder; } this.window.ClientRectangle = new System.Drawing.Rectangle(this.targetBounds.X, this.targetBounds.Y, this.targetBounds.Width, this.targetBounds.Height); DisplayDevice display = DisplayDevice.GetDisplay(DisplayIndex.Primary); this.window.X = (display.Width - this.window.Width) / 2; this.window.Y = (display.Height - this.window.Height) / 2; }
public override List <Resolution> SupportedResolutions() => DisplayDevice.GetDisplay(0).AvailableResolutions.Select(a => new Resolution { Height = a.Height, Width = a.Width, Bpp = a.BitsPerPixel, RefreshRate = (int)a.RefreshRate }).ToList();
public override void FullScreen() { DisplayDevice device = DisplayDevice.GetDisplay(0); device.ChangeResolution(width, height, 32, -1); window.WindowBorder = WindowBorder.Hidden; window.WindowState = WindowState.Fullscreen; }
public OptionsMenu() { var cur = DisplayDevice.GetDisplay(DisplayIndex.Default).SelectResolution( Program.Settings.WindowWidth, Program.Settings.WindowHeight, Program.Settings.BitsPerPixel, Program.Settings.RefreshRate); possibleDisplayResolutions = DisplayDevice.GetDisplay(DisplayIndex.Default).AvailableResolutions.Where(x => x.BitsPerPixel == cur.BitsPerPixel).ToList(); selectedRes = possibleDisplayResolutions.IndexOf(cur); }
public void CentreToScreen(Display display = null) { if (display != null) { CurrentDisplayDevice = DisplayDevice.GetDisplay((DisplayIndex)display.Index); } Position = new Vector2(0.5f); }
public BaseGame() : base( Size.Width, Size.Height, GraphicsMode.Default, gameProperties.windowTitle, GlobalSettings.Default.fullscreenMode ? GameWindowFlags.Fullscreen : GameWindowFlags.FixedWindow, DisplayDevice.GetDisplay((DisplayIndex)GlobalSettings.Default.monitor), 4, 6, GraphicsContextFlags.ForwardCompatible) { }
private void UpdateDisplayBounds() { bounds = Rectangle.Empty; for (DisplayIndex i = DisplayIndex.First; i < DisplayIndex.Sixth; i++) { DisplayDevice display = DisplayDevice.GetDisplay(i); if (display != null) { bounds = Rectangle.Union(bounds, display.Bounds); } } }
private static void Main(string[] args) { Console.WriteLine("Vector hardware acceleration: " + System.Numerics.Vector.IsHardwareAccelerated); using (var game = new SurvivalGame()) { game.Title = "Test Game"; game.VSync = VSyncMode.Adaptive; game.X = (DisplayDevice.GetDisplay(DisplayIndex.Default).Width - game.Width) / 2; game.Y = (DisplayDevice.GetDisplay(DisplayIndex.Default).Height - game.Height) / 2; game.Run(120); } }
private List <DisplayDevice> GetDisplayDevices() { List <DisplayDevice> displayDevices = new List <DisplayDevice>((int)DisplayIndex.Sixth + 1); for (var display = DisplayIndex.First; display <= DisplayIndex.Sixth; display++) { var device = DisplayDevice.GetDisplay(display); if (device != null) { displayDevices.Add(device); } } return(displayDevices); }
public void UpdateAll() { Program.Window.WindowState = Fullscreen ? OpenTK.WindowState.Fullscreen : OpenTK.WindowState.Normal; Program.Window.ClientSize = new System.Drawing.Size(WindowWidth, WindowHeight); Program.Window.ClientRectangle = new System.Drawing.Rectangle(0, 0, WindowWidth, WindowHeight); if (Fullscreen) { DisplayDevice.GetDisplay(DisplayIndex.Default).ChangeResolution(DisplayDevice.GetDisplay(DisplayIndex.Default) .SelectResolution(WindowWidth, WindowHeight, BitsPerPixel, RefreshRate)); } else { DisplayDevice.GetDisplay(DisplayIndex.Default).RestoreResolution(); } }
public IList <DisplayDevice> DiscoverAvailableDevices() { var availableDisplayDevices = new List <DisplayDevice>(); foreach (DisplayIndex index in Enum.GetValues(typeof(DisplayIndex))) { DisplayDevice device = DisplayDevice.GetDisplay(index); if (device == null) { continue; } availableDisplayDevices.Add(device); } return(availableDisplayDevices); }
public static Settings Load() { if (File.Exists(SaveLocation)) { return(JsonConvert.DeserializeObject <Settings>(File.ReadAllText(SaveLocation))); } return(new Settings() { WindowWidth = DisplayDevice.GetDisplay(DisplayIndex.Default).Width, WindowHeight = DisplayDevice.GetDisplay(DisplayIndex.Default).Height, RefreshRate = DisplayDevice.GetDisplay(DisplayIndex.Default).RefreshRate, FieldOfView = 65, Input = new InputSettings() }); }
static void Main(string[] args) { Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); using (var game = new IslandGame()) { game.Title = "Test Game"; game.VSync = VSyncMode.Off; game.Width = 1280; game.Height = 720; game.X = (DisplayDevice.GetDisplay(DisplayIndex.Default).Width - game.Width) / 2; game.Y = (DisplayDevice.GetDisplay(DisplayIndex.Default).Height - game.Height) / 2; game.Run(60); } //new Octree(new Vector3(0, 0, 0), 1, 2); }
private static DisplayDevice GetPrimaryDisplay() { DisplayDevice currentDisplay = DisplayDevice.GetDisplay(DisplayIndex.Default); for (sbyte display = -1; display < 8; display++) { currentDisplay = DisplayDevice.GetDisplay((DisplayIndex)display); if (currentDisplay == null) { break; } if (currentDisplay.IsPrimary) { break; } } return(currentDisplay); }
static void Main() { Console.WriteLine("Hello, world!"); //Get the primary display device DisplayDevice cur_display = DisplayDevice.GetDisplay(DisplayIndex.Primary); Console.WriteLine(cur_display); //Create a window GameWindow dispWindow = new GameWindow(); dispWindow.Run(); // Keep the console window open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
public static void Main() { for (int i = 0; i < 6; i++) { DisplayDevice dev = DisplayDevice.GetDisplay(DisplayIndex.First + i); if (dev != null) { Trace.WriteLine(dev.ToString()); MessageBox.Show(dev.ToString()); dev.ChangeResolution(dev.SelectResolution(640, 480, 32, 60.0f)); Thread.Sleep(1000); MessageBox.Show(dev.ToString()); dev.RestoreResolution(); Thread.Sleep(1000); MessageBox.Show(dev.ToString()); } } }
private void load(FrameworkConfigManager config, GameHost host) { window = host.Window as DesktopGameWindow; config.BindWith(FrameworkSetting.WindowMode, windowMode); if (window == null) { Console.WriteLine("No suitable window found"); return; } refreshScreens(); AddStep("set up screens", refreshScreens); const string desc1 = "Check whether the borderless window is properly set to the top left corner, even if it is obstructed by the taskbar"; const string desc2 = "Check whether the window size is one pixel wider than the screen in each direction"; for (int i = 0;; i++) { var display = DisplayDevice.GetDisplay((DisplayIndex)i); if (display == null) { break; } // set up window AddStep("switch to windowed", () => windowMode.Value = WindowMode.Windowed); AddStep("set client size to 1280x720", () => window.ClientSize = new Size(1280, 720)); AddStep("center window on screen " + i, () => window.CentreToScreen(display)); // borderless alignment tests AddStep("switch to borderless", () => windowMode.Value = WindowMode.Borderless); AddAssert("check window location", () => window.Location == display.Bounds.Location, desc1); AddAssert("check window size", () => new Size(window.Width - 1, window.Height - 1) == display.Bounds.Size, desc2); AddAssert("check current screen", () => window.CurrentDisplay == display); // verify the window size is restored correctly AddStep("switch to windowed", () => windowMode.Value = WindowMode.Windowed); AddAssert("check client size", () => window.ClientSize == new Size(1280, 720)); AddAssert("check window position", () => Math.Abs(window.Position.X - 0.5f) < 0.01 && Math.Abs(window.Position.Y - 0.5f) < 0.01); AddAssert("check current screen", () => window.CurrentDisplay == display); } }
public static DisplayIndex GetIndex(this DisplayDevice display) { if (display == null) { return(DisplayIndex.Default); } for (int i = 0; true; i++) { var device = DisplayDevice.GetDisplay((DisplayIndex)i); if (device == null) { return(DisplayIndex.Default); } if (device == display) { return((DisplayIndex)i); } } }
private void ToggleFullscreen() { DisplayDevice defaultDisplayDevice = DisplayDevice.GetDisplay(DisplayIndex.Default); if (WindowState == WindowState.Fullscreen) { WindowState = WindowState.Normal; CursorVisible = true; defaultDisplayDevice.RestoreResolution(); } else { WindowState = WindowState.Fullscreen; CursorVisible = false; defaultDisplayDevice .ChangeResolution( Const.DISPLAY_FULLHD_W, Const.DISPLAY_FULLHD_H, Const.DISPLAY_BITPERPIXEL, Const.DISPLAY_REFRESH_RATE); } }
public void ApplyWindowSettings(DisplayResolution res, bool fullscreen) { Fullscreen = fullscreen; WindowWidth = res.Width; WindowHeight = res.Height; RefreshRate = res.RefreshRate; BitsPerPixel = res.BitsPerPixel; Program.Window.ClientSize = new System.Drawing.Size(WindowWidth, WindowHeight); Program.Window.ClientRectangle = new System.Drawing.Rectangle(0, 0, WindowWidth, WindowHeight); if (Fullscreen) { DisplayDevice.GetDisplay(DisplayIndex.Default).ChangeResolution(res); } else { DisplayDevice.GetDisplay(DisplayIndex.Default).RestoreResolution(); } Program.Window.WindowState = Fullscreen ? OpenTK.WindowState.Fullscreen : OpenTK.WindowState.Normal; Save(); }
private void SetCenteredFullScreenWindow(Point position) { int x = position.X; int actualX = 0; Size size = default(Size); DisplayIndex index = DisplayIndex.Default; while (x >= 0) { var display = DisplayDevice.GetDisplay(index); x -= display.Width; if (x > 0) { actualX += display.Width; } else { size = new Size(display.Width, display.Height); } index += 1; } if (size == default(Size)) { throw new InvalidOperationException("SetCenteredFullScreen failed. Couldn't determine size."); } var bounds = _nativeWindow.Bounds; bounds.X = actualX; bounds.Y = 0; bounds.Width = size.Width; bounds.Height = size.Height; _nativeWindow.Bounds = bounds; }
public ShaderWindow(ShaderWindowSettings configuration) : this(configuration, DisplayDevice.GetDisplay(configuration.DisplayDevice) ?? DisplayDevice.Default) { }
private void windowDisplayIndexChanged(ValueChangedEvent <DisplayIndex> args) => CurrentDisplay = DisplayDevice.GetDisplay(args.NewValue);
protected OsuTKDesktopWindow() : base(default_width, default_height) { Resize += OnResize; Move += OnMove; // Changing the CurrentDisplay bindable should update the position of the window accordingly. // Note that this must be done on the windowing thread to avoid potential deadlocks or strange behaviour. CurrentDisplayBindable.ValueChanged += evt => UpdateFrameScheduler.Add(() => CurrentDisplayDevice = DisplayDevice.GetDisplay((DisplayIndex)evt.NewValue.Index)); }
private void windowDisplayIndexChanged(DisplayIndex index) => CurrentDisplay = DisplayDevice.GetDisplay(index);