diff --git a/AUTHORS b/AUTHORS
index 2b98d1eca5..07efee67ae 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -188,6 +188,8 @@ distributed under MIT License.
Using Json.NET developed by James Newton-King
distributed under MIT License.
+Using ANGLE distributed under the BS3 3-Clause license.
+
This site or product includes IP2Location LITE data
available from http://www.ip2location.com.
diff --git a/Makefile b/Makefile
index 6e505ca2c5..20bb7c74ee 100644
--- a/Makefile
+++ b/Makefile
@@ -171,6 +171,9 @@ ifeq ($(TARGETPLATFORM), $(filter $(TARGETPLATFORM),win-x86 win-x64))
@$(INSTALL_PROGRAM) SDL2.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) freetype6.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) lua51.dll "$(DATA_INSTALL_DIR)"
+ @$(INSTALL_PROGRAM) libEGL.dll "$(DATA_INSTALL_DIR)"
+ @$(INSTALL_PROGRAM) libGLESv2.dll "$(DATA_INSTALL_DIR)"
+
endif
ifeq ($(TARGETPLATFORM), linux-x64)
@-echo "Installing OpenRA dependencies to $(DATA_INSTALL_DIR)"
diff --git a/OpenRA.Game/Graphics/PlatformInterfaces.cs b/OpenRA.Game/Graphics/PlatformInterfaces.cs
index 60c29271f4..55281c149d 100644
--- a/OpenRA.Game/Graphics/PlatformInterfaces.cs
+++ b/OpenRA.Game/Graphics/PlatformInterfaces.cs
@@ -18,6 +18,7 @@ namespace OpenRA
public enum GLProfile
{
Automatic,
+ ANGLE,
Modern,
Embedded,
Legacy
diff --git a/OpenRA.Platforms.Default/OpenRA.Platforms.Default.csproj b/OpenRA.Platforms.Default/OpenRA.Platforms.Default.csproj
index e725d63726..0d3a6f806d 100644
--- a/OpenRA.Platforms.Default/OpenRA.Platforms.Default.csproj
+++ b/OpenRA.Platforms.Default/OpenRA.Platforms.Default.csproj
@@ -29,7 +29,7 @@
-
+
diff --git a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs
index 9f143f4acd..c2d55be89f 100644
--- a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs
+++ b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs
@@ -10,6 +10,7 @@
#endregion
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
@@ -146,14 +147,11 @@ namespace OpenRA.Platforms.Default
SetProcessDPIAware();
// Decide which OpenGL profile to use.
- // We first need to query the available profiles on Windows/Linux.
- // On macOS, known/consistent OpenGL support is provided by the OS.
- if (Platform.CurrentPlatform == PlatformType.OSX)
- supportedProfiles = new[] { GLProfile.Modern, GLProfile.Legacy };
- else
- supportedProfiles = new[] { GLProfile.Modern, GLProfile.Embedded, GLProfile.Legacy }
- .Where(CanCreateGLWindow)
- .ToArray();
+ // Prefer standard GL over GLES provided by the native driver
+ var testProfiles = new List { GLProfile.ANGLE, GLProfile.Modern, GLProfile.Embedded, GLProfile.Legacy };
+ supportedProfiles = testProfiles
+ .Where(CanCreateGLWindow)
+ .ToArray();
if (!supportedProfiles.Any())
throw new InvalidOperationException("No supported OpenGL profiles were found.");
@@ -471,6 +469,9 @@ namespace OpenRA.Platforms.Default
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_BLUE_SIZE, 8);
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_ALPHA_SIZE, 0);
+ var useAngle = profile == GLProfile.ANGLE ? "1" : "0";
+ SDL.SDL_SetHint("SDL_OPENGL_ES_DRIVER", useAngle);
+
switch (profile)
{
case GLProfile.Modern:
@@ -478,6 +479,7 @@ namespace OpenRA.Platforms.Default
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, (int)SDL.SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_CORE);
break;
+ case GLProfile.ANGLE:
case GLProfile.Embedded:
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 0);
@@ -516,10 +518,18 @@ namespace OpenRA.Platforms.Default
return false;
}
+ // Distinguish between ANGLE and native GLES
+ var success = true;
+ if (profile == GLProfile.ANGLE || profile == GLProfile.Embedded)
+ {
+ var isAngle = SDL.SDL_GL_ExtensionSupported("GL_ANGLE_texture_usage") == SDL.SDL_bool.SDL_TRUE;
+ success = isAngle ^ (profile != GLProfile.ANGLE);
+ }
+
SDL.SDL_GL_DeleteContext(context);
SDL.SDL_DestroyWindow(window);
SDL.SDL_Quit();
- return true;
+ return success;
}
public void SetScaleModifier(float scale)
diff --git a/packaging/windows/OpenRA.nsi b/packaging/windows/OpenRA.nsi
index 0faa932f72..188f331193 100644
--- a/packaging/windows/OpenRA.nsi
+++ b/packaging/windows/OpenRA.nsi
@@ -153,6 +153,8 @@ Section "Game" GAME
File "${SRCDIR}\DiscordRPC.dll"
File "${SRCDIR}\Newtonsoft.Json.dll"
File "${SRCDIR}\SDL2.dll"
+ File "${SRCDIR}\libEGL.dll"
+ File "${SRCDIR}\libGLESv2.dll"
File "${SRCDIR}\freetype6.dll"
File "${SRCDIR}\lua51.dll"
@@ -263,6 +265,8 @@ Function ${UN}Clean
Delete $INSTDIR\IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP
Delete $INSTDIR\soft_oal.dll
Delete $INSTDIR\SDL2.dll
+ Delete $INSTDIR\libEGL.dll
+ Delete $INSTDIR\libGLESv2.dll
Delete $INSTDIR\lua51.dll
Delete $INSTDIR\eluant.dll
Delete $INSTDIR\freetype6.dll