Skip to content

Commit

Permalink
Hide legacy GL support behind a feature flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote authored and abcdefg30 committed Oct 12, 2020
1 parent 2c0d512 commit 597b8b1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion OpenRA.Game/Graphics/PlatformInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public enum GLProfile

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);
}
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Renderer(IPlatform platform, GraphicSettings graphicSettings)

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;

Expand Down
5 changes: 4 additions & 1 deletion OpenRA.Game/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,16 @@ public class GraphicSettings
[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;

Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Platforms.Default/DefaultPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions OpenRA.Platforms.Default/Sdl2PlatformWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public GLProfile[] SupportedGLProfiles
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)
Expand All @@ -148,7 +148,10 @@ public Sdl2PlatformWindow(Size requestEffectiveWindowSize, WindowMode windowMode

// Decide which OpenGL profile to use.
// Prefer standard GL over GLES provided by the native driver
var testProfiles = new List<GLProfile> { GLProfile.ANGLE, GLProfile.Modern, GLProfile.Embedded, GLProfile.Legacy };
var testProfiles = new List<GLProfile> { GLProfile.ANGLE, GLProfile.Modern, GLProfile.Embedded };
if (enableLegacyGL)
testProfiles.Add(GLProfile.Legacy);

supportedProfiles = testProfiles
.Where(CanCreateGLWindow)
.ToArray();
Expand Down

0 comments on commit 597b8b1

Please sign in to comment.