From 597b8b1caae6ebfb61dd328048c80e2ea13e7675 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 1 Oct 2020 19:20:27 +0100 Subject: [PATCH] Hide legacy GL support behind a feature flag. --- OpenRA.Game/Graphics/PlatformInterfaces.cs | 2 +- OpenRA.Game/Renderer.cs | 2 +- OpenRA.Game/Settings.cs | 5 ++++- OpenRA.Platforms.Default/DefaultPlatform.cs | 4 ++-- OpenRA.Platforms.Default/Sdl2PlatformWindow.cs | 7 +++++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/Graphics/PlatformInterfaces.cs b/OpenRA.Game/Graphics/PlatformInterfaces.cs index 55281c149d..d879825591 100644 --- a/OpenRA.Game/Graphics/PlatformInterfaces.cs +++ b/OpenRA.Game/Graphics/PlatformInterfaces.cs @@ -26,7 +26,7 @@ namespace OpenRA public interface IPlatform { - IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int batchSize, int videoDisplay, GLProfile profile); + IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int batchSize, int videoDisplay, GLProfile profile, bool enableLegacyGL); ISoundEngine CreateSound(string device); IFont CreateFont(byte[] data); } diff --git a/OpenRA.Game/Renderer.cs b/OpenRA.Game/Renderer.cs index a5b820ac08..263dedbbc4 100644 --- a/OpenRA.Game/Renderer.cs +++ b/OpenRA.Game/Renderer.cs @@ -77,7 +77,7 @@ namespace OpenRA Window = platform.CreateWindow(new Size(resolution.Width, resolution.Height), graphicSettings.Mode, graphicSettings.UIScale, graphicSettings.BatchSize, - graphicSettings.VideoDisplay, graphicSettings.GLProfile); + graphicSettings.VideoDisplay, graphicSettings.GLProfile, !graphicSettings.DisableLegacyGL); Context = Window.Context; diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index ed27bf5ade..72310200dc 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -175,13 +175,16 @@ namespace OpenRA [Desc("Disable operating-system provided cursor rendering.")] public bool DisableHardwareCursors = false; + [Desc("Disable legacy OpenGL 2.1 support.")] + public bool DisableLegacyGL = true; + [Desc("Display index to use in a multi-monitor fullscreen setup.")] public int VideoDisplay = 0; [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.", + "Legacy: OpenGL 2.1 with framebuffer_object extension (requires DisableLegacyGL: False)", "Automatic: Use the first supported profile.")] public GLProfile GLProfile = GLProfile.Automatic; diff --git a/OpenRA.Platforms.Default/DefaultPlatform.cs b/OpenRA.Platforms.Default/DefaultPlatform.cs index 419c4c8433..ed91fb95ca 100644 --- a/OpenRA.Platforms.Default/DefaultPlatform.cs +++ b/OpenRA.Platforms.Default/DefaultPlatform.cs @@ -16,9 +16,9 @@ namespace OpenRA.Platforms.Default { public class DefaultPlatform : IPlatform { - public IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int batchSize, int videoDisplay, GLProfile profile) + public IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int batchSize, int videoDisplay, GLProfile profile, bool enableLegacyGL) { - return new Sdl2PlatformWindow(size, windowMode, scaleModifier, batchSize, videoDisplay, profile); + return new Sdl2PlatformWindow(size, windowMode, scaleModifier, batchSize, videoDisplay, profile, enableLegacyGL); } public ISoundEngine CreateSound(string device) diff --git a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs index c2d55be89f..f9fc46c23b 100644 --- a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs +++ b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs @@ -135,7 +135,7 @@ namespace OpenRA.Platforms.Default static extern bool SetProcessDPIAware(); public Sdl2PlatformWindow(Size requestEffectiveWindowSize, WindowMode windowMode, - float scaleModifier, int batchSize, int videoDisplay, GLProfile requestProfile) + float scaleModifier, int batchSize, int videoDisplay, GLProfile requestProfile, bool enableLegacyGL) { // Lock the Window/Surface properties until initialization is complete lock (syncObject) @@ -148,7 +148,10 @@ namespace OpenRA.Platforms.Default // Decide which OpenGL profile to use. // Prefer standard GL over GLES provided by the native driver - var testProfiles = new List { GLProfile.ANGLE, GLProfile.Modern, GLProfile.Embedded, GLProfile.Legacy }; + var testProfiles = new List { GLProfile.ANGLE, GLProfile.Modern, GLProfile.Embedded }; + if (enableLegacyGL) + testProfiles.Add(GLProfile.Legacy); + supportedProfiles = testProfiles .Where(CanCreateGLWindow) .ToArray();