public CarbonGLNative(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { CreateNativeWindow(WindowClass.Document, WindowAttributes.StandardDocument | WindowAttributes.StandardHandler | WindowAttributes.InWindowMenu | WindowAttributes.LiveResize, new Rect((short)x, (short)y, (short)width, (short)height)); }
public override void Load() { _screens = new List<Screen>(Screen.AllScreens); IList<String> options = new List<String>(); options.Add("[Settings.Appearance.System.StartupScreen.DoNotUseSelection]"); foreach (Screen screen in Screen.AllScreens) { const int dwf = 0; DisplayDevice info = new DisplayDevice(); string monitorname = null; info.cb = Marshal.SizeOf(info); if (EnumDisplayDevices(screen.DeviceName, 0, info, dwf)) monitorname = info.DeviceString; options.Add(string.Format("{0} ({1}x{2})", monitorname, screen.Bounds.Width, screen.Bounds.Height)); } int startupScreenNum = SettingsManager.Load<StartupSettings>().StartupScreenNum; if (startupScreenNum < Screen.AllScreens.Length) Selected = SettingsManager.Load<StartupSettings>().StartupScreenNum + 1; else Selected = 0; _items = options.Select(LocalizationHelper.CreateResourceString).ToList(); }
public SDL2GLNative(int x, int y, int width, int height, string title, GraphicsMode mode,GameWindowFlags options, DisplayDevice device) : this() { if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be higher than zero."); if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be higher than zero."); Debug.Indent(); IntPtr windowId; desiredSizeX = width; desiredSizeY = height; isFullscreen = options.HasFlag(GameWindowFlags.Fullscreen); if (isFullscreen) { FixupFullscreenRes(width,height,out width, out height); } lock (API.sdl_api_lock) { API.Init (API.INIT_VIDEO); API.VideoInit("",0); // NOTE: Seriously, letting the user set x and y coords is a _bad_ idea. We'll let the WM take care of it. windowId = API.CreateWindow(title, 0x1FFF0000, 0x1FFF0000, width, height, API.WindowFlags.OpenGL | ((isFullscreen)?API.WindowFlags.Fullscreen:0)); } window = new SDL2WindowInfo(windowId); inputDriver = new SDL2Input(window); Debug.Unindent(); }
static X11DisplayDevice() { List<DisplayDevice> devices = new List<DisplayDevice>(); try { xinerama_supported = QueryXinerama(devices); } catch { Debug.Print("Xinerama query failed."); } if (!xinerama_supported) { // We assume that devices are equivalent to the number of available screens. // Note: this won't work correctly in the case of distinct X servers. for (int i = 0; i < API.ScreenCount; i++) { DisplayDevice dev = new DisplayDevice(); dev.IsPrimary = i == API.XDefaultScreen(API.DefaultDisplay); devices.Add(dev); deviceToScreen.Add(dev, i); } } try { xrandr_supported = QueryXRandR(devices); } catch { } if (!xrandr_supported) { Debug.Print("XRandR query failed, falling back to XF86."); try { xf86_supported = QueryXF86(devices); } catch { } if (!xf86_supported) { Debug.Print("XF86 query failed, no DisplayDevice support available."); } } }
public LinuxNativeWindow(IntPtr display, IntPtr gbm, int fd, int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice display_device) { Debug.Print("[KMS] Creating window on display {0:x}", display); Title = title; display_device = display_device ?? DisplayDevice.Default; if (display_device == null) { throw new NotSupportedException("[KMS] Driver does not currently support headless systems"); } window = new LinuxWindowInfo(display, fd, gbm, display_device.Id as LinuxDisplay); // Note: we only support fullscreen windows on KMS. // We implicitly override the requested width and height // by the width and height of the DisplayDevice, if any. width = display_device.Width; height = display_device.Height; bounds = new Rectangle(0, 0, width, height); client_size = bounds.Size; if (!mode.Index.HasValue) { mode = new EglGraphicsMode().SelectGraphicsMode(window, mode, 0); } Debug.Print("[KMS] Selected EGL mode {0}", mode); SurfaceFormat format = GetSurfaceFormat(display, mode); SurfaceFlags usage = SurfaceFlags.Rendering | SurfaceFlags.Scanout; if (!Gbm.IsFormatSupported(gbm, format, usage)) { Debug.Print("[KMS] Failed to find suitable surface format, using XRGB8888"); format = SurfaceFormat.XRGB8888; } Debug.Print("[KMS] Creating GBM surface on {0:x} with {1}x{2} {3} [{4}]", gbm, width, height, format, usage); IntPtr gbm_surface = Gbm.CreateSurface(gbm, width, height, format, usage); if (gbm_surface == IntPtr.Zero) { throw new NotSupportedException("[KMS] Failed to create GBM surface for rendering"); } window.Handle = gbm_surface; Debug.Print("[KMS] Created GBM surface {0:x}", window.Handle); window.CreateWindowSurface(mode.Index.Value); Debug.Print("[KMS] Created EGL surface {0:x}", window.Surface); cursor_default = CreateCursor(gbm, Cursors.Default); cursor_empty = CreateCursor(gbm, Cursors.Empty); Cursor = MouseCursor.Default; exists = true; }
new Dictionary<DisplayDevice, string>(); // Needed for ChangeDisplaySettingsEx #region --- Constructors --- /// <summary>Queries available display devices and display resolutions.</summary> static WinDisplayDeviceDriver() { lock (display_lock) { // To minimize the need to add static methods to OpenTK.Graphics.DisplayDevice // we only allow settings to be set through its constructor. // Thus, we save all necessary parameters in temporary variables // and construct the device when every needed detail is available. // The main DisplayDevice constructor adds the newly constructed device // to the list of available devices. DisplayDevice opentk_dev; DisplayResolution opentk_dev_current_res = null; List<DisplayResolution> opentk_dev_available_res = new List<DisplayResolution>(); bool opentk_dev_primary = false; int device_count = 0, mode_count = 0; // Get available video adapters and enumerate all monitors WindowsDisplayDevice dev1 = new WindowsDisplayDevice(), dev2 = new WindowsDisplayDevice(); while (Functions.EnumDisplayDevices(null, device_count++, dev1, 0)) { if ((dev1.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) == DisplayDeviceStateFlags.None) continue; DeviceMode monitor_mode = new DeviceMode(); // The second function should only be executed when the first one fails // (e.g. when the monitor is disabled) if (Functions.EnumDisplaySettingsEx(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.CurrentSettings, monitor_mode, 0) || Functions.EnumDisplaySettingsEx(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.RegistrySettings, monitor_mode, 0)) { opentk_dev_current_res = new DisplayResolution( monitor_mode.Position.X, monitor_mode.Position.Y, monitor_mode.PelsWidth, monitor_mode.PelsHeight, monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency); opentk_dev_primary = (dev1.StateFlags & DisplayDeviceStateFlags.PrimaryDevice) != DisplayDeviceStateFlags.None; } opentk_dev_available_res.Clear(); mode_count = 0; while (Functions.EnumDisplaySettings(dev1.DeviceName.ToString(), mode_count++, monitor_mode)) { DisplayResolution res = new DisplayResolution( monitor_mode.Position.X, monitor_mode.Position.Y, monitor_mode.PelsWidth, monitor_mode.PelsHeight, monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency); opentk_dev_available_res.Add(res); } // Construct the OpenTK DisplayDevice through the accumulated parameters. // The constructor will automatically add the DisplayDevice to the list // of available devices. opentk_dev = new DisplayDevice( opentk_dev_current_res, opentk_dev_primary, opentk_dev_available_res, opentk_dev_current_res.Bounds); available_device_names.Add(opentk_dev, dev1.DeviceName); } } }
public WinGLNative(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device) { WindowProcedureDelegate = WindowProcedure; // To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be // bound to the top-level window, but rather to a child window docked in the parent. window = new WinWindowInfo( CreateWindow(x, y, width, height, title, options, device, IntPtr.Zero), null); child_window = new WinWindowInfo( CreateWindow(0, 0, ClientSize.Width, ClientSize.Height, title, options, device, window.WindowHandle), window); exists = true; }
public sealed override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { DeviceMode mode = null; if (resolution != null) { mode = new DeviceMode(); mode.PelsWidth = resolution.Width; mode.PelsHeight = resolution.Height; mode.BitsPerPel = resolution.BitsPerPixel; mode.DisplayFrequency = (int)resolution.RefreshRate; mode.Fields = Constants.DM_BITSPERPEL | Constants.DM_PELSWIDTH | Constants.DM_PELSHEIGHT | Constants.DM_DISPLAYFREQUENCY; } return Constants.DISP_CHANGE_SUCCESSFUL == Functions.ChangeDisplaySettingsEx((string)device.Id, mode, IntPtr.Zero, ChangeDisplaySettingsEnum.Fullscreen, IntPtr.Zero); }
public Sdl2DisplayDeviceDriver() { int displays = SDL.GetNumVideoDisplays(); for (int d = 0; d < displays; d++) { Rect bounds; SDL.GetDisplayBounds(d, out bounds); DisplayMode current_mode; SDL.GetCurrentDisplayMode(d, out current_mode); var mode_list = new List<DisplayResolution>(); int num_modes = SDL.GetNumDisplayModes(d); for (int m = 0; m < num_modes; m++) { DisplayMode sdl_mode; SDL.GetDisplayMode(d, m, out sdl_mode); mode_list.Add(new DisplayResolution( bounds.X, bounds.Y, sdl_mode.Width, sdl_mode.Height, TranslateFormat(sdl_mode.Format), sdl_mode.RefreshRate)); } var current_resolution = new DisplayResolution( bounds.X, bounds.Y, current_mode.Width, current_mode.Height, TranslateFormat(current_mode.Format), current_mode.RefreshRate); var device = new DisplayDevice( current_resolution, d == 0, mode_list, TranslateBounds(bounds), d); AvailableDevices.Add(device); if (d == 0) Primary = device; } }
void RefreshDisplayDevices () { List<DisplayDevice> devices = new List<DisplayDevice> (); int numVideoDevices = 0; lock (API.sdl_api_lock) { numVideoDevices = API.GetNumVideoDisplays (); } for (int i = 0; i < numVideoDevices; ++i) { DisplayDevice dev = new DisplayDevice(); List<DisplayResolution> resolutions = new List<DisplayResolution>(); if (i == 0) dev.IsPrimary = true; int numResolutions = 0; lock (API.sdl_api_lock) { numResolutions = API.GetNumDisplayModes(i); } for (int res = 0; res < numResolutions; ++res) { lock (API.sdl_api_lock) { API.DisplayMode modeRect; API.GetDisplayMode(i, res, out modeRect); resolutions.Add (new DisplayResolution(0, 0, modeRect.w, modeRect.h, 32, modeRect.refresh_rate)); } } dev.AvailableResolutions = resolutions; devices.Add(dev); } AvailableDevices.Clear(); AvailableDevices.AddRange(devices); Primary = FindDefaultDevice(devices); }
public X11GLNative(int x, int y, int width, int height, string title, GraphicsMode mode,GameWindowFlags options, DisplayDevice device) : this() { if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be higher than zero."); if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be higher than zero."); XVisualInfo info = new XVisualInfo(); Debug.Indent(); lock (API.Lock) { if (!mode.Index.HasValue) throw new GraphicsModeException("Invalid or unsupported GraphicsMode."); info.VisualID = mode.Index.Value; int dummy; window.VisualInfo = (XVisualInfo)Marshal.PtrToStructure( Functions.XGetVisualInfo(window.Display, XVisualInfoMask.ID, ref info, out dummy), typeof(XVisualInfo)); // Create a window on this display using the visual above Debug.Write("Opening render window... "); XSetWindowAttributes attributes = new XSetWindowAttributes(); attributes.background_pixel = IntPtr.Zero; attributes.border_pixel = IntPtr.Zero; attributes.colormap = Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0/*AllocNone*/); window.EventMask = EventMask.StructureNotifyMask | EventMask.SubstructureNotifyMask | EventMask.ExposureMask | EventMask.KeyReleaseMask | EventMask.KeyPressMask | EventMask.PointerMotionMask | EventMask.FocusChangeMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask; attributes.event_mask = (IntPtr)window.EventMask; uint mask = (uint)SetWindowValuemask.ColorMap | (uint)SetWindowValuemask.EventMask | (uint)SetWindowValuemask.BackPixel | (uint)SetWindowValuemask.BorderPixel; window.WindowHandle = Functions.XCreateWindow(window.Display, window.RootWindow, x, y, width, height, 0, window.VisualInfo.Depth/*(int)CreateWindowArgs.CopyFromParent*/, (int)CreateWindowArgs.InputOutput, window.VisualInfo.Visual, (UIntPtr)mask, ref attributes); if (window.WindowHandle == IntPtr.Zero) throw new ApplicationException("XCreateWindow call failed (returned 0)."); } // Set the window hints SetWindowMinMax(_min_width, _min_height, -1, -1); XSizeHints hints = new XSizeHints(); hints.base_width = width; hints.base_height = height; hints.flags = (IntPtr)(XSizeHintsFlags.PSize | XSizeHintsFlags.PPosition); lock (API.Lock) { Functions.XSetWMNormalHints(window.Display, window.WindowHandle, ref hints); // Register for window destroy notification Functions.XSetWMProtocols(window.Display, window.WindowHandle, new IntPtr[] { _atom_wm_destroy }, 1); API.MapRaised(window.Display, window.WindowHandle); } driver = new X11Input(window); Debug.WriteLine(String.Format("X11GLNative window created successfully (id: {0}).", Handle)); Debug.Unindent(); exists = true; }
public abstract INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device);
public override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { Sdl2Factory.UseFullscreenDesktop = false; return(true); }
public override bool TryRestoreResolution(DisplayDevice device) { Sdl2Factory.UseFullscreenDesktop = true; return true; }
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { return default_implementation.CreateNativeWindow(x, y, width, height, title, mode, options, device); }
#pragma warning restore 414 #endregion #region Constructors public X11GLNative(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) : this() { if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be higher than zero."); if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be higher than zero."); Debug.Indent(); using (new XLock(window.Display)) { IntPtr visual; IntPtr fbconfig; window.GraphicsMode = new X11GraphicsMode() .SelectGraphicsMode(mode, out visual, out fbconfig); window.Visual = visual; window.FBConfig = fbconfig; // Create a window on this display using the visual above Debug.Write("Opening render window... "); XSetWindowAttributes attributes = new XSetWindowAttributes(); attributes.background_pixel = IntPtr.Zero; attributes.border_pixel = IntPtr.Zero; attributes.colormap = Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0/*AllocNone*/); window.EventMask = EventMask.StructureNotifyMask /*| EventMask.SubstructureNotifyMask*/ | EventMask.ExposureMask | EventMask.KeyReleaseMask | EventMask.KeyPressMask | EventMask.KeymapStateMask | EventMask.PointerMotionMask | EventMask.FocusChangeMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.EnterWindowMask | EventMask.LeaveWindowMask | EventMask.PropertyChangeMask; attributes.event_mask = (IntPtr)window.EventMask; SetWindowValuemask mask = SetWindowValuemask.ColorMap | SetWindowValuemask.EventMask | SetWindowValuemask.BackPixel | SetWindowValuemask.BorderPixel; window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow, x, y, width, height, 0, window.VisualInfo.Depth/*(int)CreateWindowArgs.CopyFromParent*/, CreateWindowArgs.InputOutput, window.VisualInfo.Visual, mask, attributes); if (window.Handle == IntPtr.Zero) throw new ApplicationException("XCreateWindow call failed (returned 0)."); if (title != null) Functions.XStoreName(window.Display, window.Handle, title); } XSizeHints hints = new XSizeHints(); hints.base_width = width; hints.base_height = height; hints.flags = (IntPtr)(XSizeHintsFlags.PSize | XSizeHintsFlags.PPosition); XClassHint class_hint = new XClassHint(); class_hint.Name = Assembly.GetEntryAssembly().GetName().Name.ToLower(); class_hint.Class = Assembly.GetEntryAssembly().GetName().Name; using (new XLock(window.Display)) { Functions.XSetWMNormalHints(window.Display, window.Handle, ref hints); // Register for window destroy notification Functions.XSetWMProtocols(window.Display, window.Handle, new IntPtr[] { _atom_wm_destroy }, 1); // Set the window class hints Functions.XSetClassHint(window.Display, window.Handle, ref class_hint); } SetWindowMinMax(_min_width, _min_height, -1, -1); // Set the initial window size to ensure X, Y, Width, Height and the rest // return the correct values inside the constructor and the Load event. XEvent e = new XEvent(); e.ConfigureEvent.x = x; e.ConfigureEvent.y = y; e.ConfigureEvent.width = width; e.ConfigureEvent.height = height; RefreshWindowBounds(ref e); EmptyCursor = CreateEmptyCursor(window); Debug.WriteLine(String.Format("X11GLNative window created successfully (id: {0}).", Handle)); Debug.Unindent(); using (new XLock(window.Display)) { // Request that auto-repeat is only set on devices that support it physically. // This typically means that it's turned off for keyboards (which is what we want). // We prefer this method over XAutoRepeatOff/On, because the latter needs to // be reset before the program exits. if (Xkb.IsSupported(window.Display)) { bool supported; Xkb.SetDetectableAutoRepeat(window.Display, true, out supported); } } // The XInput2 extension makes keyboard and mouse handling much easier. // Check whether it is available. xi2_supported = XI2MouseKeyboard.IsSupported(window.Display); if (xi2_supported) { xi2_opcode = XI2MouseKeyboard.XIOpCode; xi2_version = XI2MouseKeyboard.XIVersion; } exists = true; }
public override INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice display_device) { return new LinuxNativeWindow(egl_display, gbm_device, gpu_fd, x, y, width, height, title, mode, options, display_device); }
public RiftCamera(OculusRift rift, DisplayDevice display) { this.rift = rift; this.display = display; }
protected override void RestoreResolution(DisplayDevice displayDevice) { }
// Apple recommends not changing the system resolution for fullscreen access protected override void ChangeResolution(DisplayDevice display, Size newSize) => ClientSize = newSize;
public bool TryRestoreResolution(DisplayDevice device) { return(TryChangeResolution(device, null)); }
/// <summary> /// /// </summary> public override void AddConfig() { var optFullScreen = new ConfigOption("Full Screen", "No", false); var optVideoMode = new ConfigOption("Video Mode", "800 x 600", false); var optDisplayFrequency = new ConfigOption("Display Frequency", "", false); var optColorDepth = new ConfigOption("Color Depth", "", false); var optFSAA = new ConfigOption("FSAA", "0", false); var optVSync = new ConfigOption("VSync", "No", false); var optRTTMode = new ConfigOption("RTT Preferred Mode", "FBO", false); // Full Screen optFullScreen.PossibleValues.Add(0, "Yes"); optFullScreen.PossibleValues.Add(1, "No"); // Video Mode #region Video Modes // get the available OpenGL resolutions DisplayDevice dev = DisplayDevice.Default; // add the resolutions to the config for (int q = 0; q < dev.AvailableResolutions.Count; q++) { if (dev.AvailableResolutions[q].BitsPerPixel >= 16) { int width = dev.AvailableResolutions[q].Width; int height = dev.AvailableResolutions[q].Height; // filter out the lower resolutions and dupe frequencies if (width >= 640 && height >= 480) { string query = string.Format("{0} x {1}", width, height); if (!optVideoMode.PossibleValues.Values.Contains(query)) { // add a new row to the display settings table optVideoMode.PossibleValues.Add(optVideoMode.PossibleValues.Count, query); } if (optVideoMode.PossibleValues.Count == 1 && String.IsNullOrEmpty(optVideoMode.Value)) { optVideoMode.Value = query; } } } } #endregion Video Modes // FSAA GetFSAALevels(); foreach (int level in this._fsaaLevels) { optFSAA.PossibleValues.Add(level, level.ToString()); } // VSync optVSync.PossibleValues.Add(0, "Yes"); optVSync.PossibleValues.Add(1, "No"); // RTTMode optRTTMode.PossibleValues.Add(0, "FBO"); optRTTMode.PossibleValues.Add(1, "PBuffer"); optRTTMode.PossibleValues.Add(2, "Copy"); optFullScreen.ConfigValueChanged += new ConfigOption <string> .ValueChanged(_configOptionChanged); optVideoMode.ConfigValueChanged += new ConfigOption <string> .ValueChanged(_configOptionChanged); optDisplayFrequency.ConfigValueChanged += new ConfigOption <string> .ValueChanged(_configOptionChanged); optFSAA.ConfigValueChanged += new ConfigOption <string> .ValueChanged(_configOptionChanged); optVSync.ConfigValueChanged += new ConfigOption <string> .ValueChanged(_configOptionChanged); optColorDepth.ConfigValueChanged += new ConfigOption <string> .ValueChanged(_configOptionChanged); optRTTMode.ConfigValueChanged += new ConfigOption <string> .ValueChanged(_configOptionChanged); ConfigOptions.Add(optVideoMode); ConfigOptions.Add(optColorDepth); ConfigOptions.Add(optDisplayFrequency); ConfigOptions.Add(optFullScreen); ConfigOptions.Add(optFSAA); ConfigOptions.Add(optVSync); ConfigOptions.Add(optRTTMode); _refreshConfig(); }
public TizenGameWindow(GraphicsMode mode, DisplayDevice device, int major, int minor) : this(GraphicsMode.Default, DisplayDevice.Default, "", 2, 0) { }
static internal IntPtr HandleTo(DisplayDevice displayDevice) { return (IntPtr)displayDevice.Id; }
public sealed override bool TryRestoreResolution(DisplayDevice device) { IntPtr display = HandleTo(device); if (storedModes.ContainsKey(display)) { Debug.Print("Restoring resolution."); CG.DisplaySwitchToMode(display, storedModes[display]); CG.DisplayRelease(display); displaysCaptured.Remove(display); return true; } return false; }
public abstract bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution);
public bool TryRestoreResolution(DisplayDevice device) { return TryChangeResolution(device, null); }
public abstract bool TryRestoreResolution(DisplayDevice device);
private string displayConfigFriendlyName; // provided by DisplayConfig (if supported) /// <summary>Initializes a new <see cref="DisplayMonitor"/> instance.</summary> /// <param name="displayDevice">A valid <see cref="DisplayDevice"/> structure.</param> /// <param name="monitorHandle">A handle (HMONITOR) to the monitor.</param> internal DisplayMonitor( DisplayDevice displayDevice, IntPtr monitorHandle ) : base( displayDevice ) { info = GetMonitorInfo( handle = monitorHandle ); }
public X11GLNative(int x, int y, int width, int height, string title, GraphicsMode mode, DisplayDevice device) { if (width <= 0) { throw new ArgumentOutOfRangeException("width", "Must be higher than zero."); } if (height <= 0) { throw new ArgumentOutOfRangeException("height", "Must be higher than zero."); } Debug.Print("Creating X11GLNative window."); // Open a display connection to the X server, and obtain the screen and root window. window.Display = API.DefaultDisplay; window.Screen = API.XDefaultScreen(window.Display); //API.DefaultScreen; window.RootWindow = API.XRootWindow(window.Display, window.Screen); // API.RootWindow; Debug.Print("Display: {0}, Screen {1}, Root window: {2}", window.Display, window.Screen, window.RootWindow); RegisterAtoms(window); XVisualInfo info = new XVisualInfo(); mode = X11GLContext.SelectGraphicsMode(mode, out info); window.VisualInfo = info; // Create a window on this display using the visual above Debug.Print("Opening render window... "); XSetWindowAttributes attributes = new XSetWindowAttributes(); attributes.background_pixel = IntPtr.Zero; attributes.border_pixel = IntPtr.Zero; attributes.colormap = API.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0 /*AllocNone*/); window.EventMask = EventMask.StructureNotifyMask /*| EventMask.SubstructureNotifyMask*/ | EventMask.ExposureMask | EventMask.KeyReleaseMask | EventMask.KeyPressMask | EventMask.KeymapStateMask | EventMask.PointerMotionMask | EventMask.FocusChangeMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.EnterWindowMask | EventMask.LeaveWindowMask | EventMask.PropertyChangeMask; attributes.event_mask = (IntPtr)window.EventMask; uint mask = (uint)SetWindowValuemask.ColorMap | (uint)SetWindowValuemask.EventMask | (uint)SetWindowValuemask.BackPixel | (uint)SetWindowValuemask.BorderPixel; window.WindowHandle = API.XCreateWindow(window.Display, window.RootWindow, x, y, width, height, 0, window.VisualInfo.Depth /*(int)CreateWindowArgs.CopyFromParent*/, (int)CreateWindowArgs.InputOutput, window.VisualInfo.Visual, (IntPtr)mask, ref attributes); if (window.WindowHandle == IntPtr.Zero) { throw new ApplicationException("XCreateWindow call failed (returned 0)."); } if (title != null) { API.XStoreName(window.Display, window.WindowHandle, title); } // Set the window hints SetWindowMinMax(_min_width, _min_height, -1, -1); XSizeHints hints = new XSizeHints(); hints.base_width = width; hints.base_height = height; hints.flags = (IntPtr)(XSizeHintsFlags.PSize | XSizeHintsFlags.PPosition); API.XSetWMNormalHints(window.Display, window.WindowHandle, ref hints); // Register for window destroy notification API.XSetWMProtocols(window.Display, window.WindowHandle, new IntPtr[] { wm_destroy }, 1); // Set the initial window size to ensure X, Y, Width, Height and the rest // return the correct values inside the constructor and the Load event. XEvent e = new XEvent(); e.ConfigureEvent.x = x; e.ConfigureEvent.y = y; e.ConfigureEvent.width = width; e.ConfigureEvent.height = height; RefreshWindowBounds(ref e); Debug.Print("X11GLNative window created successfully (id: {0}).", Handle); SetupInput(); exists = true; }
public WinGLNative(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device) { lock (SyncRoot) { // This is the main window procedure callback. We need the callback in order to create the window, so // don't move it below the CreateWindow calls. WindowProcedureDelegate = WindowProcedure; //// This timer callback is called periodically when the window enters a sizing / moving modal loop. //ModalLoopCallback = delegate(IntPtr handle, WindowMessage msg, UIntPtr eventId, int time) //{ // // Todo: find a way to notify the frontend that it should process queued up UpdateFrame/RenderFrame events. // if (Move != null) // Move(this, EventArgs.Empty); //}; int scale_width = width; int scale_height = height; int scale_x = x; int scale_y = y; if (Toolkit.Options.EnableHighResolution) { // CreateWindow takes values in pixels. // According to the high-dpi guidelines, // we need to scale these values by the // current DPI. // Search MSDN for "How to Ensure That // Your Application Displays Properly on // High-DPI Displays" scale_width = ScaleX(width); scale_height = ScaleY(height); scale_x = ScaleX(x); scale_y = ScaleY(y); } // To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be // bound to the top-level window, but rather to a child window docked in the parent. window = new WinWindowInfo( CreateWindow( scale_x, scale_y, scale_width, scale_height, title, options, device, IntPtr.Zero), null); child_window = new WinWindowInfo( CreateWindow( 0, 0, ClientSize.Width, ClientSize.Height, title, options, device, window.Handle), window); exists = true; keyboard.Description = "Standard Windows keyboard"; keyboard.NumberOfFunctionKeys = 12; keyboard.NumberOfKeys = 101; keyboard.NumberOfLeds = 3; mouse.Description = "Standard Windows mouse"; mouse.NumberOfButtons = 3; mouse.NumberOfWheels = 1; keyboards.Add(keyboard); mice.Add(mouse); } }
public CarbonGLNative(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device) { this.title = title; CreateNativeWindow(WindowClass.Document, WindowAttributes.StandardDocument | WindowAttributes.StandardHandler | WindowAttributes.InWindowMenu | WindowAttributes.LiveResize, new Rect((short)x, (short)y, (short)width, (short)height)); mDisplayDevice = device; }
public X11GLNative(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) : this() { if (width <= 0) { throw new ArgumentOutOfRangeException("width", "Must be higher than zero."); } if (height <= 0) { throw new ArgumentOutOfRangeException("height", "Must be higher than zero."); } XVisualInfo template = new XVisualInfo(); using (new XLock(this.window.Display)) { if (!mode.Index.HasValue) { throw new GraphicsModeException("Invalid or unsupported GraphicsMode."); } template.VisualID = mode.Index.Value; int nitems; this.window.VisualInfo = (XVisualInfo)Marshal.PtrToStructure(Functions.XGetVisualInfo(this.window.Display, XVisualInfoMask.ID, ref template, out nitems), typeof(XVisualInfo)); XSetWindowAttributes attributes = new XSetWindowAttributes(); attributes.background_pixel = IntPtr.Zero; attributes.border_pixel = IntPtr.Zero; attributes.colormap = Functions.XCreateColormap(this.window.Display, this.window.RootWindow, this.window.VisualInfo.Visual, 0); this.window.EventMask = EventMask.KeyPressMask | EventMask.KeyReleaseMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.EnterWindowMask | EventMask.LeaveWindowMask | EventMask.PointerMotionMask | EventMask.KeymapStateMask | EventMask.ExposureMask | EventMask.StructureNotifyMask | EventMask.FocusChangeMask | EventMask.PropertyChangeMask; attributes.event_mask = (IntPtr)((long)this.window.EventMask); uint num = 10250U; this.window.WindowHandle = Functions.XCreateWindow(this.window.Display, this.window.RootWindow, x, y, width, height, 0, this.window.VisualInfo.Depth, 1, this.window.VisualInfo.Visual, (UIntPtr)num, ref attributes); if (this.window.WindowHandle == IntPtr.Zero) { throw new ApplicationException("XCreateWindow call failed (returned 0)."); } if (title != null) { Functions.XStoreName(this.window.Display, this.window.WindowHandle, title); } } this.SetWindowMinMax((short)30, (short)30, (short)-1, (short)-1); XSizeHints hints = new XSizeHints(); hints.base_width = width; hints.base_height = height; hints.flags = (IntPtr)12L; using (new XLock(this.window.Display)) { Functions.XSetWMNormalHints(this.window.Display, this.window.WindowHandle, ref hints); Functions.XSetWMProtocols(this.window.Display, this.window.WindowHandle, new IntPtr[1] { this._atom_wm_destroy }, 1); } this.RefreshWindowBounds(ref new XEvent() { ConfigureEvent = { x = x, y = y, width = width, height = height } }); this.driver = new X11Input((IWindowInfo)this.window); this.mouse = this.driver.Mouse[0]; this.EmptyCursor = X11GLNative.CreateEmptyCursor(this.window); this.exists = true; }
public WinGLNative(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device) { lock (SyncRoot) { // This is the main window procedure callback. We need the callback in order to create the window, so // don't move it below the CreateWindow calls. WindowProcedureDelegate = WindowProcedure; //// This timer callback is called periodically when the window enters a sizing / moving modal loop. //ModalLoopCallback = delegate(IntPtr handle, WindowMessage msg, UIntPtr eventId, int time) //{ // // Todo: find a way to notify the frontend that it should process queued up UpdateFrame/RenderFrame events. // if (Move != null) // Move(this, EventArgs.Empty); //}; // To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be // bound to the top-level window, but rather to a child window docked in the parent. window = new WinWindowInfo( CreateWindow(x, y, width, height, title, options, device, IntPtr.Zero), null); child_window = new WinWindowInfo( CreateWindow(0, 0, ClientSize.Width, ClientSize.Height, title, options, device, window.WindowHandle), window); exists = true; keyboard.Description = "Standard Windows keyboard"; keyboard.NumberOfFunctionKeys = 12; keyboard.NumberOfKeys = 101; keyboard.NumberOfLeds = 3; mouse.Description = "Standard Windows mouse"; mouse.NumberOfButtons = 3; mouse.NumberOfWheels = 1; keyboards.Add(keyboard); mice.Add(mouse); } }
public override bool TryRestoreResolution(DisplayDevice device) { Sdl2Factory.UseFullscreenDesktop = true; return(true); }
protected virtual void RestoreResolution(DisplayDevice displayDevice) => displayDevice.RestoreResolution();
private MouseCursor selectedCursor = MouseCursor.Default; // user-selected cursor public CocoaNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { // Create the window class Interlocked.Increment(ref UniqueId); windowClass = Class.AllocateClass("OpenTK_GameWindow" + UniqueId, "NSWindow"); Class.RegisterMethod(windowClass, new WindowKeyDownDelegate(WindowKeyDown), "keyDown:", "v@:@"); Class.RegisterMethod(windowClass, new WindowDidResizeDelegate(WindowDidResize), "windowDidResize:", "v@:@"); Class.RegisterMethod(windowClass, new WindowDidMoveDelegate(WindowDidMove), "windowDidMove:", "v@:@"); Class.RegisterMethod(windowClass, new WindowDidBecomeKeyDelegate(WindowDidBecomeKey), "windowDidBecomeKey:", "v@:@"); Class.RegisterMethod(windowClass, new WindowDidResignKeyDelegate(WindowDidResignKey), "windowDidResignKey:", "v@:@"); Class.RegisterMethod(windowClass, new WindowWillMiniaturizeDelegate(WindowWillMiniaturize), "windowWillMiniaturize:", "v@:@"); Class.RegisterMethod(windowClass, new WindowDidMiniaturizeDelegate(WindowDidMiniaturize), "windowDidMiniaturize:", "v@:@"); Class.RegisterMethod(windowClass, new WindowDidDeminiaturizeDelegate(WindowDidDeminiaturize), "windowDidDeminiaturize:", "v@:@"); Class.RegisterMethod(windowClass, new WindowShouldZoomToFrameDelegate(WindowShouldZoomToFrame), "windowShouldZoom:toFrame:", "b@:@{NSRect={NSPoint=ff}{NSSize=ff}}"); Class.RegisterMethod(windowClass, new WindowShouldCloseDelegate(WindowShouldClose), "windowShouldClose:", "b@:@"); Class.RegisterMethod(windowClass, new AcceptsFirstResponderDelegate(AcceptsFirstResponder), "acceptsFirstResponder", "b@:"); Class.RegisterMethod(windowClass, new CanBecomeKeyWindowDelegate(CanBecomeKeyWindow), "canBecomeKeyWindow", "b@:"); Class.RegisterMethod(windowClass, new CanBecomeMainWindowDelegate(CanBecomeMainWindow), "canBecomeMainWindow", "b@:"); Class.RegisterClass(windowClass); IntPtr viewClass = Class.AllocateClass("OpenTK_NSView" + UniqueId, "NSView"); Class.RegisterMethod(viewClass, new ResetCursorRectsDelegate(ResetCursorRects), "resetCursorRects", "v@:"); Class.RegisterClass(viewClass); // Create window instance // Note: The coordinate system of Cocoa places (0,0) at the bottom left. // We need to get the height of the main screen and flip that in order // to place the window at the correct position. // Note: NSWindows are laid out relative to the main screen. var screenRect = Cocoa.SendRect( Cocoa.SendIntPtr( Cocoa.SendIntPtr(Class.Get("NSScreen"), Selector.Get("screens")), Selector.Get("objectAtIndex:"), 0), Selector.Get("frame")); var contentRect = new System.Drawing.RectangleF(x, screenRect.Height - height - y, width, height); var style = GetStyleMask(windowBorder); var bufferingType = NSBackingStore.Buffered; IntPtr windowPtr; windowPtr = Cocoa.SendIntPtr(windowClass, Selector.Alloc); windowPtr = Cocoa.SendIntPtr(windowPtr, Selector.Get("initWithContentRect:styleMask:backing:defer:"), contentRect, (int)style, (int)bufferingType, false); // Replace view with our custom implementation // that overrides resetCursorRects (maybe there is // a better way to implement this override?) // Existing view: IntPtr viewPtr = Cocoa.SendIntPtr(windowPtr, Selector.Get("contentView")); // Our custom view with the same bounds: viewPtr = Cocoa.SendIntPtr( Cocoa.SendIntPtr(viewClass, Selector.Alloc), Selector.Get("initWithFrame:"), Cocoa.SendRect(viewPtr, selBounds)); if (viewPtr != IntPtr.Zero) { Cocoa.SendVoid(windowPtr, Selector.Get("setContentView:"), viewPtr); } windowInfo = new CocoaWindowInfo(windowPtr); // Set up behavior Cocoa.SendIntPtr(windowPtr, Selector.Get("setDelegate:"), windowPtr); // The window class acts as its own delegate Cocoa.SendVoid(windowPtr, Selector.Get("makeKeyWindow")); SetTitle(title, false); ResetTrackingArea(); exists = true; NSApplication.Quit += ApplicationQuit; }
private void windowDisplayIndexChanged(ValueChangedEvent <DisplayIndex> args) => CurrentDisplay = DisplayDevice.GetDisplay(args.NewValue);
public Window(int width, int height, string title, DisplayDevice displayDevice) : base(width, height, GraphicsMode.Default, title, GameWindowFlags.Default, displayDevice) { }
static QuartzDisplayDeviceDriver() { lock (display_lock) { // To minimize the need to add static methods to OpenTK.Graphics.DisplayDevice // we only allow settings to be set through its constructor. // Thus, we save all necessary parameters in temporary variables // and construct the device when every needed detail is available. // The main DisplayDevice constructor adds the newly constructed device // to the list of available devices. const int maxDisplayCount = 20; IntPtr[] displays = new IntPtr[maxDisplayCount]; int displayCount; unsafe { fixed(IntPtr* displayPtr = displays) { CG.GetActiveDisplayList(maxDisplayCount, displayPtr, out displayCount); } } Debug.Print("CoreGraphics reported {0} display(s).", displayCount); Debug.Indent(); for (int i = 0; i < displayCount; i++) { IntPtr currentDisplay = displays[i]; // according to docs, first element in the array is always the // main display. bool primary = (i == 0); if (primary) mainDisplay = currentDisplay; // gets current settings int currentWidth = CG.DisplayPixelsWide(currentDisplay); int currentHeight = CG.DisplayPixelsHigh(currentDisplay); Debug.Print("Display {0} is at {1}x{2}", i, currentWidth, currentHeight); IntPtr displayModesPtr = CG.DisplayAvailableModes(currentDisplay); CFArray displayModes = new CFArray(displayModesPtr); Debug.Print("Supports {0} display modes.", displayModes.Count); DisplayResolution opentk_dev_current_res = null; List<DisplayResolution> opentk_dev_available_res = new List<DisplayResolution>(); IntPtr currentModePtr = CG.DisplayCurrentMode(currentDisplay); CFDictionary currentMode = new CFDictionary(currentModePtr); for (int j = 0; j < displayModes.Count; j++) { CFDictionary dict = new CFDictionary(displayModes[j]); int width = (int) dict.GetNumberValue("Width"); int height = (int) dict.GetNumberValue("Height"); int bpp = (int) dict.GetNumberValue("BitsPerPixel"); double freq = dict.GetNumberValue("RefreshRate"); bool current = currentMode.Ref == dict.Ref; //if (current) Debug.Write(" * "); //else Debug.Write(" "); //Debug.Print("Mode {0} is {1}x{2}x{3} @ {4}.", j, width, height, bpp, freq); DisplayResolution thisRes = new DisplayResolution(0, 0, width, height, bpp, (float)freq); opentk_dev_available_res.Add(thisRes); if (current) opentk_dev_current_res = thisRes; } HIRect bounds = CG.DisplayBounds(currentDisplay); Rectangle newRect = new Rectangle( (int)bounds.Origin.X, (int)bounds.Origin.Y, (int)bounds.Size.Width, (int)bounds.Size.Height); Debug.Print("Display {0} bounds: {1}", i, newRect); DisplayDevice opentk_dev = new DisplayDevice(opentk_dev_current_res, primary, opentk_dev_available_res, newRect); displayMap.Add(opentk_dev, currentDisplay); } Debug.Unindent(); } }
public sealed override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { IntPtr display = HandleTo(device); IntPtr currentModePtr = CG.DisplayCurrentMode(display); if (storedModes.ContainsKey(display) == false) { storedModes.Add(display, currentModePtr); } IntPtr displayModesPtr = CG.DisplayAvailableModes(display); CFArray displayModes = new CFArray(displayModesPtr); for (int j = 0; j < displayModes.Count; j++) { CFDictionary dict = new CFDictionary(displayModes[j]); int width = (int)dict.GetNumberValue("Width"); int height = (int)dict.GetNumberValue("Height"); int bpp = (int)dict.GetNumberValue("BitsPerPixel"); double freq = dict.GetNumberValue("RefreshRate"); if (width == resolution.Width && height == resolution.Height && bpp == resolution.BitsPerPixel && System.Math.Abs(freq - resolution.RefreshRate) < 1e-6) { if (displaysCaptured.Contains(display) == false) { CG.DisplayCapture(display); } Debug.Print("Changing resolution to {0}x{1}x{2}@{3}.", width, height, bpp, freq); CG.DisplaySwitchToMode(display, displayModes[j]); return true; } } return false; }
public QuartzDisplayDeviceDriver() { lock (display_lock) { // To minimize the need to add static methods to OpenTK.Graphics.DisplayDevice // we only allow settings to be set through its constructor. // Thus, we save all necessary parameters in temporary variables // and construct the device when every needed detail is available. // The main DisplayDevice constructor adds the newly constructed device // to the list of available devices. const int maxDisplayCount = 20; IntPtr[] displays = new IntPtr[maxDisplayCount]; int displayCount; unsafe { fixed (IntPtr* displayPtr = displays) { CG.GetActiveDisplayList(maxDisplayCount, displayPtr, out displayCount); } } Debug.Print("CoreGraphics reported {0} display(s).", displayCount); Debug.Indent(); for (int i = 0; i < displayCount; i++) { IntPtr currentDisplay = displays[i]; // according to docs, first element in the array is always the // main display. bool primary = (i == 0); // gets current settings int currentWidth = CG.DisplayPixelsWide(currentDisplay); int currentHeight = CG.DisplayPixelsHigh(currentDisplay); Debug.Print("Display {0} is at {1}x{2}", i, currentWidth, currentHeight); IntPtr displayModesPtr = CG.DisplayAvailableModes(currentDisplay); CFArray displayModes = new CFArray(displayModesPtr); Debug.Print("Supports {0} display modes.", displayModes.Count); DisplayResolution opentk_dev_current_res = null; List<DisplayResolution> opentk_dev_available_res = new List<DisplayResolution>(); IntPtr currentModePtr = CG.DisplayCurrentMode(currentDisplay); CFDictionary currentMode = new CFDictionary(currentModePtr); for (int j = 0; j < displayModes.Count; j++) { CFDictionary dict = new CFDictionary(displayModes[j]); int width = (int)dict.GetNumberValue("Width"); int height = (int)dict.GetNumberValue("Height"); int bpp = (int)dict.GetNumberValue("BitsPerPixel"); double freq = dict.GetNumberValue("RefreshRate"); bool current = currentMode.Ref == dict.Ref; //if (current) Debug.Write(" * "); //else Debug.Write(" "); //Debug.Print("Mode {0} is {1}x{2}x{3} @ {4}.", j, width, height, bpp, freq); DisplayResolution thisRes = new DisplayResolution(0, 0, width, height, bpp, (float)freq); opentk_dev_available_res.Add(thisRes); if (current) opentk_dev_current_res = thisRes; } HIRect bounds = CG.DisplayBounds(currentDisplay); Rectangle newRect = new Rectangle((int)bounds.Origin.X, (int)bounds.Origin.Y, (int)bounds.Size.Width, (int)bounds.Size.Height); Debug.Print("Display {0} bounds: {1}", i, newRect); DisplayDevice opentk_dev = new DisplayDevice(opentk_dev_current_res, primary, opentk_dev_available_res, newRect, currentDisplay); AvailableDevices.Add(opentk_dev); if (primary) Primary = opentk_dev; } Debug.Unindent(); } }
public override INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { throw new NotImplementedException(); }
public override INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { return new Sdl2NativeWindow(x, y, width, height, title, options, device); }
private static extern bool EnumDisplayDevices(IntPtr lpDevice, int iDevNum, ref DisplayDevice lpDisplayDevice, int dwFlags);
public static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, ref DisplayDevice lpDisplayDevice, uint dwFlags);
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { return(Default.CreateNativeWindow(x, y, width, height, title, mode, options, device)); }
public override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution) { Sdl2Factory.UseFullscreenDesktop = false; return true; }
public CrowWindow(int width, int height, OpenTK.Graphics.GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device, int major, int minor, OpenTK.Graphics.GraphicsContextFlags flags) : base(width, height, mode, title, options, device, major, minor, flags) { }
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { throw new PlatformNotSupportedException(error_string); }
/// <summary> /// Converts an osuTK <see cref="DisplayDevice"/> to a <see cref="Display"/> structure. /// </summary> /// <param name="device">The <see cref="DisplayDevice"/> to convert.</param> /// <returns>A <see cref="Display"/> structure populated with the corresponding properties and <see cref="DisplayMode"/>s.</returns> internal static Display ToDisplay(this DisplayDevice device) => new Display((int)device.GetIndex(), device.GetIndex().ToString(), device.Bounds, device.AvailableResolutions.Select(ToDisplayMode).ToArray());
IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle) { // Use win32 to create the native window. // Keep in mind that some construction code runs in the WM_CREATE message handler. // The style of a parent window is different than that of a child window. // Note: the child window should always be visible, even if the parent isn't. WindowStyle style = 0; ExtendedWindowStyle ex_style = 0; if (parentHandle == IntPtr.Zero) { style |= WindowStyle.OverlappedWindow | WindowStyle.ClipChildren; ex_style = ParentStyleEx; } else { style |= WindowStyle.Visible | WindowStyle.Child | WindowStyle.ClipSiblings; ex_style = ChildStyleEx; } // Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc). Win32Rectangle rect = new Win32Rectangle(); rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height; API.AdjustWindowRectEx(ref rect, style, false, ex_style); // Create the window class that we will use for this window. // The current approach is to register a new class for each top-level WinGLWindow we create. if (!class_registered) { ExtendedWindowClass wc = new ExtendedWindowClass(); wc.Size = ExtendedWindowClass.SizeInBytes; wc.Style = ClassStyle.OwnDC; wc.Instance = Instance; wc.WndProc = WindowProcedureDelegate; wc.ClassName = ClassName; wc.Icon = Icon != null ? Icon.Handle : IntPtr.Zero; #warning "This seems to resize one of the 'large' icons, rather than using a small icon directly (multi-icon files). Investigate!" wc.IconSm = Icon != null ? new Icon(Icon, 16, 16).Handle : IntPtr.Zero; wc.Cursor = API.LoadCursor(IntPtr.Zero, (IntPtr)32512); // CursorName.Arrow ushort atom = API.RegisterClassEx(ref wc); if (atom == 0) { throw new PlatformException(String.Format("Failed to register window class. Error: {0}", Marshal.GetLastWin32Error())); } class_registered = true; } IntPtr window_name = Marshal.StringToHGlobalAuto(title); IntPtr handle = API.CreateWindowEx( ex_style, ClassName, window_name, style, rect.left, rect.top, rect.Width, rect.Height, parentHandle, IntPtr.Zero, Instance, IntPtr.Zero); if (handle == IntPtr.Zero) { throw new PlatformException(String.Format("Failed to create window. Error: {0}", Marshal.GetLastWin32Error())); } return(handle); }
IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle) { // Use win32 to create the native window. // Keep in mind that some construction code runs in the WM_CREATE message handler. // The style of a parent window is different than that of a child window. // Note: the child window should always be visible, even if the parent isn't. WindowStyle style = 0; ExtendedWindowStyle ex_style = 0; if (parentHandle == IntPtr.Zero) { style |= WindowStyle.OverlappedWindow | WindowStyle.ClipChildren; ex_style = ParentStyleEx; } else { style |= WindowStyle.Visible | WindowStyle.Child | WindowStyle.ClipSiblings; ex_style = ChildStyleEx; } // Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc). Win32Rectangle rect = new Win32Rectangle(); rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height; Functions.AdjustWindowRectEx(ref rect, style, false, ex_style); // Create the window class that we will use for this window. // The current approach is to register a new class for each top-level WinGLWindow we create. if (!class_registered) { ExtendedWindowClass wc = new ExtendedWindowClass(); wc.Size = ExtendedWindowClass.SizeInBytes; wc.Style = DefaultClassStyle; wc.Instance = Instance; wc.WndProc = WindowProcedureDelegate; wc.ClassName = ClassName; wc.Icon = Icon != null ? Icon.Handle : IntPtr.Zero; #warning "This seems to resize one of the 'large' icons, rather than using a small icon directly (multi-icon files). Investigate!" wc.IconSm = Icon != null ? new Icon(Icon, 16, 16).Handle : IntPtr.Zero; wc.Cursor = Functions.LoadCursor(CursorName.Arrow); ushort atom = Functions.RegisterClassEx(ref wc); if (atom == 0) throw new PlatformException(String.Format("Failed to register window class. Error: {0}", Marshal.GetLastWin32Error())); class_registered = true; } IntPtr window_name = Marshal.StringToHGlobalAuto(title); IntPtr handle = Functions.CreateWindowEx( ex_style, ClassName, window_name, style, rect.left, rect.top, rect.Width, rect.Height, parentHandle, IntPtr.Zero, Instance, IntPtr.Zero); if (handle == IntPtr.Zero) throw new PlatformException(String.Format("Failed to create window. Error: {0}", Marshal.GetLastWin32Error())); return handle; }
public override INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { throw new PlatformNotSupportedException(error_string); }
public TizenGameWindow(GraphicsMode mode, DisplayDevice device, string title, int major, int minor) : base(device.Width, device.Height, mode, title, GameWindowFlags.Fullscreen, device, major, minor, GraphicsContextFlags.Embedded) { SDL2.SDL.SetHint("SDL_IOS_ORIENTATIONS", "Portrait LandscapeLeft LandscapeRight PortraitUpsideDown"); Paused = false; }
public virtual INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { return new X11GLNative(x, y, width, height, title, mode, options, device); }
public override INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) { return(new X11GLNative(x, y, width, height, title, mode, options, device)); }