/// <summary>Constructs a new GameWindow with the specified attributes.</summary> /// <param name="width">The width of the GameWindow in pixels.</param> /// <param name="height">The height of the GameWindow in pixels.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param> /// <param name="title">The title of the GameWindow.</param> /// <param name="options">GameWindow options regarding window appearance and behavior.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param> public GameWindow(int width, int height, GraphicsMode mode, string title, bool nullContext, GameWindowFlags options, DisplayDevice device) : base(width, height, title, options, mode, device) { try { glContext = nullContext ? new NullContext() : Factory.Default.CreateGLContext(mode, WindowInfo); glContext.MakeCurrent(WindowInfo); glContext.LoadAll(); VSync = true; } catch (Exception e) { Debug.Print(e.ToString()); base.Dispose(); throw; } }
public Sdl2NativeWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device) { lock (sync) { var bounds = device.Bounds; var flags = TranslateFlags(options); flags |= WindowFlags.OPENGL; flags |= WindowFlags.RESIZABLE; flags |= WindowFlags.HIDDEN; flags |= WindowFlags.ALLOW_HIGHDPI; if ((flags & WindowFlags.FULLSCREEN_DESKTOP) != 0 || (flags & WindowFlags.FULLSCREEN) != 0) window_state = WindowState.Fullscreen; IntPtr handle; lock (SDL.Sync) { EventFilterDelegate = Marshal.GetFunctionPointerForDelegate(EventFilterDelegate_GCUnsafe); handle = SDL.CreateWindow(title, bounds.Left + x, bounds.Top + y, width, height, flags); SDL.AddEventWatch(EventFilterDelegate, handle); SDL.PumpEvents(); } window = new Sdl2WindowInfo(handle, null); window_id = SDL.GetWindowID(handle); windows.Add(window_id, this); window_title = title; exists = true; } }
public Sdl2NativeWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device) { lock (sync) { var bounds = device.Bounds; var flags = TranslateFlags(options); flags |= WindowFlags.OPENGL; flags |= WindowFlags.HIDDEN; if (Toolkit.Options.EnableHighResolution) { flags |= WindowFlags.ALLOW_HIGHDPI; } if ((flags & WindowFlags.FULLSCREEN_DESKTOP) != 0 || (flags & WindowFlags.FULLSCREEN) != 0) window_state = WindowState.Fullscreen; if ((flags & WindowFlags.RESIZABLE) == 0) window_border = WindowBorder.Fixed; IntPtr handle; lock (SDL.Sync) { handle = SDL.CreateWindow(title, bounds.Left + x, bounds.Top + y, width, height, flags); exists = true; } ProcessEvents(); window = new Sdl2WindowInfo(handle, null); window_id = SDL.GetWindowID(handle); windows.Add(window_id, this); } }
public override sealed bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { IntPtr num1 = QuartzDisplayDeviceDriver.HandleTo(device); IntPtr num2 = CG.DisplayCurrentMode(num1); if (!this.storedModes.ContainsKey(num1)) this.storedModes.Add(num1, num2); CFArray cfArray = new CFArray(CG.DisplayAvailableModes(num1)); for (int index = 0; index < cfArray.Count; ++index) { CFDictionary cfDictionary = new CFDictionary(cfArray[index]); int num3 = (int) cfDictionary.GetNumberValue("Width"); int num4 = (int) cfDictionary.GetNumberValue("Height"); int num5 = (int) cfDictionary.GetNumberValue("BitsPerPixel"); double numberValue = cfDictionary.GetNumberValue("RefreshRate"); if (num3 == resolution.Width && num4 == resolution.Height && (num5 == resolution.BitsPerPixel && Math.Abs(numberValue - (double) resolution.RefreshRate) < 1E-06)) { if (!this.displaysCaptured.Contains(num1)) { int num6 = (int) CG.DisplayCapture(num1); } CG.DisplaySwitchToMode(num1, cfArray[index]); return true; } } return false; }
public override sealed bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { if (this.xrandr_supported) return this.ChangeResolutionXRandR(device, resolution); if (this.xf86_supported) return X11DisplayDevice.ChangeResolutionXF86(device, resolution); else return false; }
public static void Main() { OpenTK.DisplayDevice chosenDisplay = OpenTK.DisplayDevice.Default; using (var application = new Application(chosenDisplay)) { application.Run(30); } }
public Application(OpenTK.DisplayDevice display) : base(640, 480, new GraphicsMode(), "example.UI", 0, display, 2, 1, GraphicsContextFlags.Default // In releases, ask for 3.3 only if you really need it. // Test forward compatible during development, but never ship with it set //3, 3, GraphicsContextFlags.ForwardCompatible ) { windowViewport = new Viewport(640, 480); }
public static void Main() { OpenTK.DisplayDevice chosenDisplay = OpenTK.DisplayDevice.Default; using (var application = new Application(chosenDisplay)) { application.Title = "example.RenderToTexture"; application.Run(30); } }
public COutput(DisplayDevice glDisplayDevice, int index) { this.glDisplayDevice = glDisplayDevice; outputDesc = new OutputDescription { DeviceName = string.Format("Display{0}", index.ToString(CultureInfo.InvariantCulture)), DesctopCoordinates = new Rectangle(), AttachedToDesctop = false, Rotation = ModeRotation.Unspecified, MonitorHandle = glDisplayDevice }; }
public override sealed bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { DeviceMode lpDevMode = (DeviceMode) null; if (resolution != (DisplayResolution) null) { lpDevMode = new DeviceMode(); lpDevMode.PelsWidth = resolution.Width; lpDevMode.PelsHeight = resolution.Height; lpDevMode.BitsPerPel = resolution.BitsPerPixel; lpDevMode.DisplayFrequency = (int) resolution.RefreshRate; lpDevMode.Fields = 6029312; } return 0 == Functions.ChangeDisplaySettingsEx((string) device.Id, lpDevMode, IntPtr.Zero, ChangeDisplaySettingsEnum.Fullscreen, IntPtr.Zero); }
public Application(OpenTK.DisplayDevice display) : base( 640, 480, new GraphicsMode(), "RenderStack", 0, display, 3, 2, GraphicsContextFlags.Default // Test forward compatible during development, but never ship with it set //3, 3, GraphicsContextFlags.ForwardCompatible ) { }
public Application(OpenTK.DisplayDevice display) : base( 640, 480, new GraphicsMode(), "RenderStack", 0, display, 2, 1, GraphicsContextFlags.ForwardCompatible | GraphicsContextFlags.Debug ) { }
public DefaultWindow(DefaultDevice device, int width, int height, ref SwapChainDescription implicitSwapChainDescription, string title, GameWindowFlags gameWindowFlags, DisplayDevice displayDevice, ref Context glContext) : base(width, height, GraphicsMode.Default, title, gameWindowFlags, displayDevice) { glContext = glContext ?? new Context(Context); this.glContext = glContext; this.device = device; implicitSwapChainDesc = implicitSwapChainDescription; swapChainSurfaces = new SwapChainSurfaces(device, width, height, ref implicitSwapChainDescription); keyboard = new Keyboard(this); mouse = new Mouse(this); }
/// <summary> /// Creates a new DisplayResolution object for the specified DisplayDevice. /// </summary> /// <param name="width">The requested width in pixels.</param> /// <param name="height">The requested height in pixels.</param> /// <param name="bitsPerPixel">The requested bits per pixel in bits.</param> /// <param name="refreshRate">The requested refresh rate in hertz.</param> /// <remarks>OpenTK will select the closest match between all available resolutions on the specified DisplayDevice.</remarks> /// public DisplayResolution(int width, int height, int bitsPerPixel, float refreshRate, DisplayDevice device) { // Refresh rate may be zero, since this information may not be available on some platforms. if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be greater than zero."); if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be greater than zero."); if (bitsPerPixel <= 0) throw new ArgumentOutOfRangeException("bitsPerPixel", "Must be greater than zero."); if (refreshRate < 0) throw new ArgumentOutOfRangeException("refreshRate", "Must be greater than, or equal to zero."); if (device == null) throw new ArgumentNullException("DisplayDevice", "Must be a valid DisplayDevice"); DisplayResolution res = device.SelectResolution(width, height, bitsPerPixel, refreshRate); this.width = res.width; this.height = res.height; this.bits_per_pixel = res.bits_per_pixel; this.refresh_rate = res.refresh_rate; }
internal DisplayDevice(DisplayResolution currentResolution, bool primary, IEnumerable<DisplayResolution> availableResolutions) { this.current_resolution = currentResolution; this.primary = primary; this.available_resolutions.AddRange(availableResolutions); Debug.Print("DisplayDevice {0} ({1}) supports {2} resolutions.", available_displays.Count, primary ? "primary" : "secondary", available_resolutions.Count); lock (display_lock) { available_displays.Add(this); if (primary) primary_display = this; } }
public RenderWindow(int width, int height, DisplayDevice device) : base(width, height, "RenderOutput", GameWindowFlags.Default, GraphicsMode.Default, device == null ? DisplayDevice.AvailableDisplays.FirstOrDefault(row => row.IsPrimary) : device) { try { glContext = new GraphicsContext(GraphicsMode.Default, WindowInfo, 2, 0, GraphicsContextFlags.Default); glContext.MakeCurrent(WindowInfo); (glContext as IGraphicsContextInternal).LoadAll(); //glWindow.WindowInfoChanged += delegate(object sender, EventArgs e) { OnWindowInfoChangedInternal(e); }; } catch (Exception e) { base.Dispose(); throw; } }
public DesktopViewController(Type rootClass, int windowWidth, int windowHeight, string windowTitle, GameWindowFlags windowFlags, DisplayDevice device, GraphicsContextFlags flags) : base(windowWidth, windowHeight, GraphicsMode.Default, windowTitle, windowFlags, device, -1, -1, flags) { Console.WriteLine("Sparrow-sharp: Starting"); _rootClass = rootClass; Load += HandleLoad; RenderFrame += HandleRenderFrame; Mouse.Move += OnMouseMove; Mouse.ButtonDown += OnMouseButtonChange; Mouse.ButtonUp += OnMouseButtonChange; // Run the game at 60 updates per second Run(60.0); }
public Program(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, GraphicsContextFlags flags, IGraphicsContext sharedContext) : base(width, height, title, options, mode == null ? GraphicsMode.Default : mode, device == null ? DisplayDevice.Default : device) { try { glContext = new GraphicsContext(mode == null ? GraphicsMode.Default : mode, WindowInfo, major, minor, flags); glContext.MakeCurrent(WindowInfo); (glContext as IGraphicsContextInternal).LoadAll(); } catch (Exception e) { Debug.Print(e.ToString()); base.Dispose(); throw; } }
public Sdl2NativeWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device) { lock (sync) { var bounds = device.Bounds; var flags = TranslateFlags(options); flags |= SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL; flags |= SDL.SDL_WindowFlags.SDL_WINDOW_RESIZABLE; flags |= SDL.SDL_WindowFlags.SDL_WINDOW_HIDDEN; if ((flags & SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP) != 0 || (flags & SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN) != 0) window_state = WindowState.Fullscreen; IntPtr handle; lock (SDL.Sync) { handle = SDL.SDL_CreateWindow(title, bounds.Left + x, bounds.Top + y, width, height, flags); SDL.SDL_AddEventWatch(EventFilterDelegate, handle); SDL.SDL_PumpEvents(); } window = new Sdl2WindowInfo(handle, null); window_id = SDL.SDL_GetWindowID(handle); windows.Add(window_id, this); window_title = title; keyboard.Description = "Standard keyboard"; keyboard.NumberOfFunctionKeys = 12; keyboard.NumberOfKeys = 101; keyboard.NumberOfLeds = 3; mouse.Description = "Standard mouse"; mouse.NumberOfButtons = 3; mouse.NumberOfWheels = 1; keyboards.Add(keyboard); mice.Add(mouse); exists = true; } }
public unsafe QuartzDisplayDeviceDriver() { lock (QuartzDisplayDeviceDriver.display_lock) { IntPtr[] local_0 = new IntPtr[20]; int local_1; fixed (IntPtr* fixed_0 = local_0) { int temp_15 = (int) CG.GetActiveDisplayList(20, fixed_0, out local_1); } for (int local_3 = 0; local_3 < local_1; ++local_3) { IntPtr local_4 = local_0[local_3]; bool local_5 = local_3 == 0; CG.DisplayPixelsWide(local_4); CG.DisplayPixelsHigh(local_4); CFArray local_7 = new CFArray(CG.DisplayAvailableModes(local_4)); DisplayResolution local_8 = (DisplayResolution) null; List<DisplayResolution> local_9 = new List<DisplayResolution>(); CFDictionary local_11 = new CFDictionary(CG.DisplayCurrentMode(local_4)); for (int local_12 = 0; local_12 < local_7.Count; ++local_12) { CFDictionary local_13 = new CFDictionary(local_7[local_12]); int local_14 = (int) local_13.GetNumberValue("Width"); int local_15 = (int) local_13.GetNumberValue("Height"); int local_16 = (int) local_13.GetNumberValue("BitsPerPixel"); double local_17 = local_13.GetNumberValue("RefreshRate"); bool local_18 = local_11.Ref == local_13.Ref; DisplayResolution local_19 = new DisplayResolution(0, 0, local_14, local_15, local_16, (float) local_17); local_9.Add(local_19); if (local_18) local_8 = local_19; } HIRect local_20 = CG.DisplayBounds(local_4); Rectangle local_21 = new Rectangle((int) local_20.Origin.X, (int) local_20.Origin.Y, (int) local_20.Size.Width, (int) local_20.Size.Height); DisplayDevice local_22 = new DisplayDevice(local_8, local_5, (IEnumerable<DisplayResolution>) local_9, local_21, (object) local_4); this.AvailableDevices.Add(local_22); if (local_5) this.Primary = local_22; } } }
/// <summary>Constructs a new NativeWindow with the specified attributes.</summary> /// <param name="x">Horizontal screen space coordinate of the NativeWindow's origin.</param> /// <param name="y">Vertical screen space coordinate of the NativeWindow's origin.</param> /// <param name="width">The width of the NativeWindow in pixels.</param> /// <param name="height">The height of the NativeWindow in pixels.</param> /// <param name="title">The title of the NativeWindow.</param> /// <param name="options">GameWindow options specifying window appearance and behavior.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the NativeWindow.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the NativeWindow in.</param> /// <exception cref="System.ArgumentOutOfRangeException">If width or height is less than 1.</exception> /// <exception cref="System.ArgumentNullException">If mode or device is null.</exception> public NativeWindow(int x, int y, int width, int height, string title, GameWindowFlags options, OpenTK.Graphics.GraphicsMode mode, DisplayDevice device) { // TODO: Should a constraint be added for the position? if (width < 1) throw new ArgumentOutOfRangeException("width", "Must be greater than zero."); if (height < 1) throw new ArgumentOutOfRangeException("height", "Must be greater than zero."); if (mode == null) throw new ArgumentNullException("mode"); if (device == null) throw new ArgumentNullException("device"); this.options = options; this.device = device; implementation = (INativeWindow2)Factory.Default.CreateNativeWindow(x, y, width, height, title, mode, options, this.device); if ((options & GameWindowFlags.Fullscreen) != 0) { this.device.ChangeResolution(width, height, mode.ColorFormat.BitsPerPixel, 0); WindowState = WindowState.Fullscreen; } }
public void RefreshDisplayDevices() { lock (this.display_lock) { this.AvailableDevices.Clear(); DisplayResolution local_1 = (DisplayResolution) null; List<DisplayResolution> local_2 = new List<DisplayResolution>(); bool local_3 = false; int local_4 = 0; WindowsDisplayDevice local_6 = new WindowsDisplayDevice(); WindowsDisplayDevice temp_10 = new WindowsDisplayDevice(); while (Functions.EnumDisplayDevices((string) null, local_4++, local_6, 0)) { if ((local_6.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) != DisplayDeviceStateFlags.None) { DeviceMode local_7 = new DeviceMode(); if (Functions.EnumDisplaySettingsEx(((object) local_6.DeviceName).ToString(), DisplayModeSettingsEnum.CurrentSettings, local_7, 0) || Functions.EnumDisplaySettingsEx(((object) local_6.DeviceName).ToString(), DisplayModeSettingsEnum.RegistrySettings, local_7, 0)) { local_1 = new DisplayResolution(local_7.Position.X, local_7.Position.Y, local_7.PelsWidth, local_7.PelsHeight, local_7.BitsPerPel, (float) local_7.DisplayFrequency); local_3 = (local_6.StateFlags & DisplayDeviceStateFlags.PrimaryDevice) != DisplayDeviceStateFlags.None; } local_2.Clear(); int local_5_1 = 0; while (Functions.EnumDisplaySettings(((object) local_6.DeviceName).ToString(), local_5_1++, local_7)) { DisplayResolution local_8 = new DisplayResolution(local_7.Position.X, local_7.Position.Y, local_7.PelsWidth, local_7.PelsHeight, local_7.BitsPerPel, (float) local_7.DisplayFrequency); local_2.Add(local_8); } DisplayDevice local_0 = new DisplayDevice(local_1, local_3, (IEnumerable<DisplayResolution>) local_2, local_1.Bounds, (object) local_6.DeviceName); this.AvailableDevices.Add(local_0); if (local_3) this.Primary = local_0; } } } }
public BitmapWindow(int x, int y, int width, int height, DisplayDevice device = null) : base(x, y, width, height, device == null ? DisplayDevice.AvailableDisplays.First() : device) { }
public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, GraphicsContextFlags flags, IGraphicsContext sharedContext) : base(width, height, title, options, mode == null ? GraphicsMode.Default : mode, device == null ? DisplayDevice.Default : device) { try { this.glContext = (IGraphicsContext) new GraphicsContext(mode == null ? GraphicsMode.Default : mode, this.WindowInfo, major, minor, flags); this.glContext.MakeCurrent(this.WindowInfo); (this.glContext as IGraphicsContextInternal).LoadAll(); this.VSync = VSyncMode.On; } catch (Exception ex) { base.Dispose(); throw; } }
// TODO: Remaining constructors. /// <summary>Constructs a new centered NativeWindow with the specified attributes.</summary> /// <param name="width">The width of the NativeWindow in pixels.</param> /// <param name="height">The height of the NativeWindow in pixels.</param> /// <param name="title">The title of the NativeWindow.</param> /// <param name="options">GameWindow options specifying window appearance and behavior.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the NativeWindow.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the NativeWindow in.</param> /// <exception cref="System.ArgumentOutOfRangeException">If width or height is less than 1.</exception> /// <exception cref="System.ArgumentNullException">If mode or device is null.</exception> public NativeWindow(int width, int height, string title, GameWindowFlags options, OpenTK.Graphics.GraphicsMode mode, DisplayDevice device) : this(device.Bounds.Left + (device.Bounds.Width - width) / 2, device.Bounds.Top + (device.Bounds.Height - height) / 2, width, height, title, options, mode, device) { }
/// <summary>Constructs a new GameWindow with the specified attributes.</summary> /// <param name="width">The width of the GameWindow in pixels.</param> /// <param name="height">The height of the GameWindow in pixels.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param> /// <param name="title">The title of the GameWindow.</param> /// <param name="options">GameWindow options regarding window appearance and behavior.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param> /// <param name="major">The major version for the OpenGL GraphicsContext.</param> /// <param name="minor">The minor version for the OpenGL GraphicsContext.</param> /// <param name="flags">The GraphicsContextFlags version for the OpenGL GraphicsContext.</param> public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, GraphicsContextFlags flags) : this(width, height, mode, title, options, device, major, minor, flags, null) { }
/// <summary>Constructs a new GameWindow with the specified attributes.</summary> /// <param name="width">The width of the GameWindow in pixels.</param> /// <param name="height">The height of the GameWindow in pixels.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param> /// <param name="title">The title of the GameWindow.</param> /// <param name="options">GameWindow options regarding window appearance and behavior.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param> public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device) : this(width, height, mode, title, options, device, 1, 0, GraphicsContextFlags.Default) { }
/// <summary>Constructs a new GameWindow with the specified attributes.</summary> /// <param name="width">The width of the GameWindow in pixels.</param> /// <param name="height">The height of the GameWindow in pixels.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param> /// <param name="title">The title of the GameWindow.</param> /// <param name="options">GameWindow options regarding window appearance and behavior.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param> /// <param name="major">The major version for the OpenGL GraphicsContext.</param> /// <param name="minor">The minor version for the OpenGL GraphicsContext.</param> /// <param name="flags">The GraphicsContextFlags version for the OpenGL GraphicsContext.</param> /// <param name="sharedContext">An IGraphicsContext to share resources with.</param> public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, GraphicsContextFlags flags, IGraphicsContext sharedContext) : base(width, height, title, options, mode == null ? GraphicsMode.Default : mode, device == null ? DisplayDevice.Default : device) { try { glContext = new GraphicsContext(mode == null ? GraphicsMode.Default : mode, WindowInfo, major, minor, flags); glContext.MakeCurrent(WindowInfo); (glContext as IGraphicsContextInternal).LoadAll(); VSync = VSyncMode.On; //glWindow.WindowInfoChanged += delegate(object sender, EventArgs e) { OnWindowInfoChangedInternal(e); }; } catch (Exception e) { Debug.Print(e.ToString()); base.Dispose(); throw; } }
unsafe void AddDisplay(LinuxDisplay display) { DisplayResolution[] modes = new DisplayResolution[display.pConnector->count_modes]; DisplayResolution current; GetModes(display, modes, out current); bool is_primary = AvailableDevices.Count == 0; DisplayDevice device = new DisplayDevice(current, is_primary, modes, GetBounds(current), display); if (is_primary) { Primary = device; } UpdateDisplayIndices(display, device); Debug.Print("[KMS] Added DisplayDevice {0}", device); }
public override bool TryRestoreResolution(DisplayDevice device) { unsafe { LinuxDisplay display = (LinuxDisplay)device.Id; ModeInfo mode = display.OriginalMode; int connector_id = display.pConnector->connector_id; return Drm.ModeSetCrtc(FD, display.Id, 0, 0, 0, &connector_id, 1, &mode) == 0; } }
/// <summary> /// Creates a new DisplayResolution object for the specified DisplayDevice. /// </summary> /// <param name="width">The requested width in pixels.</param> /// <param name="height">The requested height in pixels.</param> /// <param name="bitsPerPixel">The requested bits per pixel in bits.</param> /// <param name="refreshRate">The requested refresh rate in hertz.</param> /// <remarks>OpenTK will select the closest match between all available resolutions on the specified DisplayDevice.</remarks> /// public DisplayResolution(int width, int height, int bitsPerPixel, float refreshRate, DisplayDevice device) { // Refresh rate may be zero, since this information may not be available on some platforms. if (width <= 0) { throw new ArgumentOutOfRangeException("width", "Must be greater than zero."); } if (height <= 0) { throw new ArgumentOutOfRangeException("height", "Must be greater than zero."); } if (bitsPerPixel <= 0) { throw new ArgumentOutOfRangeException("bitsPerPixel", "Must be greater than zero."); } if (refreshRate < 0) { throw new ArgumentOutOfRangeException("refreshRate", "Must be greater than, or equal to zero."); } if (device == null) { throw new ArgumentNullException("DisplayDevice", "Must be a valid DisplayDevice"); } DisplayResolution res = device.SelectResolution(width, height, bitsPerPixel, refreshRate); this.width = res.width; this.height = res.height; this.bits_per_pixel = res.bits_per_pixel; this.refresh_rate = res.refresh_rate; }
public Game(int x, int y, int width, int height, String title, bool vsync, int fps, bool fullscreen, GraphicsMode mode, DisplayDevice display) { m_vsync = vsync; m_fps = fps; Init(x, y, width, height, title, fullscreen ? GameWindowFlags.Fullscreen : GameWindowFlags.Default, mode, display ?? DisplayDevice.Default); m_window.WindowState = WindowState.Fullscreen; }
private void Init(int x, int y, int width, int height, String title, GameWindowFlags options, GraphicsMode mode, DisplayDevice display) { // window thread m_window = new NativeWindow(x, y, width, height, title, options, mode, display); m_renderables = new List<IRenderable>(); m_components = new List<IGameComponent>(); m_context = new GraphicsContext(mode, m_window.WindowInfo); m_window.Closing += window_Exiting; m_window.WindowStateChanged += window_WindowStateChanged; SetupWindow(); m_window.Visible = true; }
// TODO: Remaining constructors. #region NativeWindow(int width, int height, string title, GameWindowFlags options, GraphicsMode mode, DisplayDevice device) /// <summary>Constructs a new centered NativeWindow with the specified attributes.</summary> /// <param name="width">The width of the NativeWindow in pixels.</param> /// <param name="height">The height of the NativeWindow in pixels.</param> /// <param name="title">The title of the NativeWindow.</param> /// <param name="options">GameWindow options specifying window appearance and behavior.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the NativeWindow.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the NativeWindow in.</param> /// <exception cref="System.ArgumentOutOfRangeException">If width or height is less than 1.</exception> /// <exception cref="System.ArgumentNullException">If mode or device is null.</exception> public NativeWindow(int width, int height, string title, GameWindowFlags options, GraphicsMode mode, DisplayDevice device) : this(device.Bounds.Left + (device.Bounds.Width - width) / 2, device.Bounds.Top + (device.Bounds.Height - height) / 2, width, height, title, options, mode, device) { }
/// <summary>Constructs a new NativeWindow with the specified attributes.</summary> /// <param name="x">Horizontal screen space coordinate of the NativeWindow's origin.</param> /// <param name="y">Vertical screen space coordinate of the NativeWindow's origin.</param> /// <param name="width">The width of the NativeWindow in pixels.</param> /// <param name="height">The height of the NativeWindow in pixels.</param> /// <param name="title">The title of the NativeWindow.</param> /// <param name="options">GameWindow options specifying window appearance and behavior.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the NativeWindow.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the NativeWindow in.</param> /// <exception cref="System.ArgumentOutOfRangeException">If width or height is less than 1.</exception> /// <exception cref="System.ArgumentNullException">If mode or device is null.</exception> public NativeWindow(int x, int y, int width, int height, string title, GameWindowFlags options, GraphicsMode mode, DisplayDevice device) { // TODO: Should a constraint be added for the position? if (width < 1) { throw new ArgumentOutOfRangeException("width", "Must be greater than zero."); } if (height < 1) { throw new ArgumentOutOfRangeException("height", "Must be greater than zero."); } if (mode == null) { throw new ArgumentNullException("mode"); } this.options = options; this.device = device; this.thread_id = System.Threading.Thread.CurrentThread.ManagedThreadId; IPlatformFactory factory = Factory.Default; implementation = factory.CreateNativeWindow(x, y, width, height, title, mode, options, this.device); factory.RegisterResource(this); if ((options & GameWindowFlags.Fullscreen) != 0) { if (this.device != null) { this.device.ChangeResolution(width, height, mode.ColorFormat.BitsPerPixel, 0); } WindowState = WindowState.Fullscreen; } if ((options & GameWindowFlags.FixedWindow) != 0) { WindowBorder = WindowBorder.Fixed; } }
void UpdateDisplayIndices(LinuxDisplay display, DisplayDevice device) { if (!DisplayIds.ContainsKey(display.Id)) { Debug.Print("[KMS] Adding display {0} as {1}", display.Id, AvailableDevices.Count); DisplayIds.Add(display.Id, AvailableDevices.Count); } int index = DisplayIds[display.Id]; if (index >= AvailableDevices.Count) { AvailableDevices.Add(device); } else { AvailableDevices[index] = device; } }
public override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { unsafe { LinuxDisplay display = (LinuxDisplay)device.Id; ModeInfo* mode = GetModeInfo(display, resolution); int connector_id = display.pConnector->connector_id; if (mode != null) { return Drm.ModeSetCrtc(FD, display.Id, 0, 0, 0, &connector_id, 1, mode) == 0; } return false; } }
/// <summary>Constructs a new NativeWindow with the specified attributes.</summary> /// <param name="x">Horizontal screen space coordinate of the NativeWindow's origin.</param> /// <param name="y">Vertical screen space coordinate of the NativeWindow's origin.</param> /// <param name="width">The width of the NativeWindow in pixels.</param> /// <param name="height">The height of the NativeWindow in pixels.</param> /// <param name="title">The title of the NativeWindow.</param> /// <param name="options">GameWindow options specifying window appearance and behavior.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the NativeWindow.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the NativeWindow in.</param> /// <exception cref="System.ArgumentOutOfRangeException">If width or height is less than 1.</exception> /// <exception cref="System.ArgumentNullException">If mode or device is null.</exception> public NativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, DisplayDevice device) { // TODO: Should a constraint be added for the position? if (width < 1) { throw new ArgumentOutOfRangeException("width", "Must be greater than zero."); } if (height < 1) { throw new ArgumentOutOfRangeException("height", "Must be greater than zero."); } if (mode == null) { throw new ArgumentNullException("mode"); } if (device == null) { throw new ArgumentNullException("device"); } this.device = device; implementation = Factory.Default.CreateNativeWindow(x, y, width, height, title, mode, this.device); }
public NativeWindow(int width, int height, string title, GameWindowFlags flags, GraphicsMode mode, DisplayDevice device) : this(width, height, title, mode, device) { }
public override sealed bool TryRestoreResolution(DisplayDevice device) { return this.TryChangeResolution(device, (DisplayResolution) null); }
/// <summary>Constructs a new NativeWindow with the specified attributes.</summary> /// <param name="x">Horizontal screen space coordinate of the NativeWindow's origin.</param> /// <param name="y">Vertical screen space coordinate of the NativeWindow's origin.</param> /// <param name="width">The width of the NativeWindow in pixels.</param> /// <param name="height">The height of the NativeWindow in pixels.</param> /// <param name="title">The title of the NativeWindow.</param> /// <param name="options">GameWindow options specifying window appearance and behavior.</param> /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the NativeWindow.</param> /// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the NativeWindow in.</param> /// <exception cref="System.ArgumentOutOfRangeException">If width or height is less than 1.</exception> /// <exception cref="System.ArgumentNullException">If mode or device is null.</exception> public NativeWindow(int x, int y, int width, int height, string title, GameWindowFlags options, GraphicsMode mode, DisplayDevice device) { // TODO: Should a constraint be added for the position? if (width < 1) { throw new ArgumentOutOfRangeException("width", "Must be greater than zero."); } if (height < 1) { throw new ArgumentOutOfRangeException("height", "Must be greater than zero."); } if (mode == null) { throw new ArgumentNullException("mode"); } if (device == null) { throw new ArgumentNullException("device"); } this.options = options; this.device = device; implementation = Factory.Default.CreateNativeWindow(x, y, width, height, title, mode, options, this.device); if ((options & GameWindowFlags.Fullscreen) != 0) { this.device.ChangeResolution(width, height, mode.ColorFormat.BitsPerPixel, 0); WindowState = WindowState.Fullscreen; } }
public ProgramWindow(int width, int height, DisplayDevice device = null) : base(width, height, device == null ? DisplayDevice.AvailableDisplays.First() : device) { }