public override void CycleMode() { var currentValue = WindowMode.Value; do { switch (currentValue) { case Configuration.WindowMode.Windowed: currentValue = Configuration.WindowMode.Borderless; break; case Configuration.WindowMode.Borderless: currentValue = Configuration.WindowMode.Fullscreen; break; case Configuration.WindowMode.Fullscreen: currentValue = Configuration.WindowMode.Windowed; break; } } while (!SupportedWindowModes.Contains(currentValue) && currentValue != WindowMode.Value); WindowMode.Value = currentValue; }
/// <summary> /// Creates a <see cref="GameWindow"/> with a given <see cref="IGameWindow"/> implementation. /// </summary> protected GameWindow([NotNull] IGameWindow implementation) { Implementation = implementation; Implementation.KeyDown += OnKeyDown; Closing += (sender, e) => e.Cancel = ExitRequested?.Invoke() ?? false; Closed += (sender, e) => Exited?.Invoke(); MouseEnter += (sender, args) => CursorInWindow = true; MouseLeave += (sender, args) => CursorInWindow = false; FocusedChanged += (o, e) => isActive.Value = Focused; SupportedWindowModes.AddRange(DefaultSupportedWindowModes); bool firstUpdate = true; UpdateFrame += (o, e) => { if (firstUpdate) { isActive.Value = Focused; firstUpdate = false; } }; WindowStateChanged += (o, e) => isActive.Value = WindowState != WindowState.Minimized; MakeCurrent(); string version = GL.GetString(StringName.Version); string versionNumberSubstring = getVersionNumberSubstring(version); GLVersion = new Version(versionNumberSubstring); // As defined by https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glGetString.xml IsEmbedded = version.Contains("OpenGL ES"); version = GL.GetString(StringName.ShadingLanguageVersion); if (!string.IsNullOrEmpty(version)) { try { GLSLVersion = new Version(versionNumberSubstring); } catch (Exception e) { Logger.Error(e, $@"couldn't set GLSL version using string '{version}'"); } } if (GLSLVersion == null) { GLSLVersion = new Version(); } Logger.Log($@"GL Initialized GL Version: {GL.GetString(StringName.Version)} GL Renderer: {GL.GetString(StringName.Renderer)} GL Shader Language version: {GL.GetString(StringName.ShadingLanguageVersion)} GL Vendor: {GL.GetString(StringName.Vendor)} GL Extensions: {GL.GetString(StringName.Extensions)}"); Context.MakeCurrent(null); }