Package and default to GLES via ANGLE on windows.

This commit is contained in:
Paul Chote
2020-10-01 19:14:06 +01:00
committed by abcdefg30
parent 87c5cc96ad
commit 2c0d512727
6 changed files with 30 additions and 10 deletions

View File

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

View File

@@ -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)"

View File

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

View File

@@ -29,7 +29,7 @@
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj" />
<PackageReference Include="OpenRA-Freetype6" Version="1.0.4" />
<PackageReference Include="OpenRA-OpenAL-CS" Version="1.0.16" />
<PackageReference Include="OpenRA-SDL2-CS" Version="1.0.27" />
<PackageReference Include="OpenRA-SDL2-CS" Version="1.0.28" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<AdditionalFiles Include="../stylecop.json" />

View File

@@ -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> { 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)

View File

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