Add an "Automatic" GL profile.

This commit is contained in:
Paul Chote
2020-10-01 18:47:06 +01:00
committed by abcdefg30
parent fc844cfa6d
commit 87c5cc96ad
4 changed files with 14 additions and 7 deletions

View File

@@ -17,6 +17,7 @@ namespace OpenRA
{
public enum GLProfile
{
Automatic,
Modern,
Embedded,
Legacy

View File

@@ -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;

View File

@@ -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<WorldViewportSizes>().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.

View File

@@ -267,9 +267,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var glProfileLabel = new CachedTransform<GLProfile, string>(p => p.ToString());
var glProfileDropdown = panel.Get<DropDownButtonWidget>("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<DropDownButtonWidget>("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)