diff --git a/OpenRA.Game/Graphics/PlatformInterfaces.cs b/OpenRA.Game/Graphics/PlatformInterfaces.cs index 92c3ae5973..60c29271f4 100644 --- a/OpenRA.Game/Graphics/PlatformInterfaces.cs +++ b/OpenRA.Game/Graphics/PlatformInterfaces.cs @@ -17,6 +17,7 @@ namespace OpenRA { public enum GLProfile { + Automatic, Modern, Embedded, Legacy diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 7713c22b96..ed27bf5ade 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -181,8 +181,9 @@ namespace OpenRA [Desc("Preferred OpenGL profile to use.", "Modern: OpenGL Core Profile 3.2 or greater.", "Embedded: OpenGL ES 3.0 or greater.", - "Legacy: OpenGL 2.1 with framebuffer_object extension.")] - public GLProfile GLProfile = GLProfile.Modern; + "Legacy: OpenGL 2.1 with framebuffer_object extension.", + "Automatic: Use the first supported profile.")] + public GLProfile GLProfile = GLProfile.Automatic; public int BatchSize = 8192; public int SheetSize = 2048; diff --git a/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs index 1d992930b5..cb6b11d6bf 100644 --- a/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs @@ -105,18 +105,21 @@ namespace OpenRA.Mods.Common.LoadScreens public virtual bool BeforeLoad() { + var graphicSettings = Game.Settings.Graphics; + // Reset the UI scaling if the user has configured a UI scale that pushes us below the minimum allowed effective resolution var minResolution = ModData.Manifest.Get().MinEffectiveResolution; var resolution = Game.Renderer.Resolution; if ((resolution.Width < minResolution.Width || resolution.Height < minResolution.Height) && Game.Settings.Graphics.UIScale > 1.0f) { - Game.Settings.Graphics.UIScale = 1.0f; + graphicSettings.UIScale = 1.0f; Game.Renderer.SetUIScale(1.0f); } // Saved settings may have been invalidated by a hardware change - Game.Settings.Graphics.GLProfile = Game.Renderer.GLProfile; - Game.Settings.Graphics.VideoDisplay = Game.Renderer.CurrentDisplay; + graphicSettings.VideoDisplay = Game.Renderer.CurrentDisplay; + if (graphicSettings.GLProfile != GLProfile.Automatic && graphicSettings.GLProfile != Game.Renderer.GLProfile) + graphicSettings.GLProfile = GLProfile.Automatic; // If a ModContent section is defined then we need to make sure that the // required content is installed or switch to the defined content installer. diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 200a6a8646..5ee9c28e34 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -267,9 +267,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic var glProfileLabel = new CachedTransform(p => p.ToString()); var glProfileDropdown = panel.Get("GL_PROFILE_DROPDOWN"); + var disableProfile = Game.Renderer.SupportedGLProfiles.Length < 2 && ds.GLProfile == GLProfile.Automatic; glProfileDropdown.OnMouseDown = _ => ShowGLProfileDropdown(glProfileDropdown, ds); glProfileDropdown.GetText = () => glProfileLabel.Update(ds.GLProfile); - glProfileDropdown.IsDisabled = () => Game.Renderer.SupportedGLProfiles.Length < 2; + glProfileDropdown.IsDisabled = () => disableProfile; var statusBarsDropDown = panel.Get("STATUS_BAR_DROPDOWN"); statusBarsDropDown.OnMouseDown = _ => ShowStatusBarsDropdown(statusBarsDropDown, gs); @@ -893,7 +894,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic return item; }; - dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Game.Renderer.SupportedGLProfiles, setupItem); + var profiles = new[] { GLProfile.Automatic }.Concat(Game.Renderer.SupportedGLProfiles); + dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, profiles, setupItem); } static void ShowTargetLinesDropdown(DropDownButtonWidget dropdown, GameSettings s)