From 24ebb54971d5ed3f4d2484a70a9a5a017696dcd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 24 Sep 2024 13:35:36 +0200 Subject: [PATCH] Use OpenGL ES graphics backend per default on Android As Vulkan crashes immediately on launch on a lot of Android devices (for around 15% of users that commented on the Android beta on Discord). The previous usage of the OpenGL backend in the shortcuts was incorrect, as this backend is not strictly available on Android and the GLES backend should be used instead, as this is also what is displayed in the graphics settings. --- scripts/android/files/java/org/ddnet/client/NativeMain.java | 4 ++-- scripts/android/files/res/values/strings.xml | 2 +- scripts/android/files/res/xml/shortcuts.xml | 6 +++--- src/engine/shared/config_variables.h | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/android/files/java/org/ddnet/client/NativeMain.java b/scripts/android/files/java/org/ddnet/client/NativeMain.java index fc994236d..e56d4cebc 100644 --- a/scripts/android/files/java/org/ddnet/client/NativeMain.java +++ b/scripts/android/files/java/org/ddnet/client/NativeMain.java @@ -29,8 +29,8 @@ public class NativeMain extends SDLActivity { if(gfxBackend != null) { if(gfxBackend.equals("Vulkan")) { launchArguments = new String[] {"gfx_backend Vulkan"}; - } else if(gfxBackend.equals("OpenGL")) { - launchArguments = new String[] {"gfx_backend OpenGL"}; + } else if(gfxBackend.equals("GLES")) { + launchArguments = new String[] {"gfx_backend GLES"}; } } } diff --git a/scripts/android/files/res/values/strings.xml b/scripts/android/files/res/values/strings.xml index 24bbf05b0..c9b6483ce 100644 --- a/scripts/android/files/res/values/strings.xml +++ b/scripts/android/files/res/values/strings.xml @@ -2,5 +2,5 @@ DDNet Play (Vulkan) - Play (OpenGL) + Play (OpenGL ES) diff --git a/scripts/android/files/res/xml/shortcuts.xml b/scripts/android/files/res/xml/shortcuts.xml index 558afd216..c2ebe2357 100644 --- a/scripts/android/files/res/xml/shortcuts.xml +++ b/scripts/android/files/res/xml/shortcuts.xml @@ -14,17 +14,17 @@ + android:shortcutShortLabel="@string/shortcut_play_gles_short"> + android:value="GLES" /> diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index ccdc95d9f..05373fa5b 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -717,7 +717,9 @@ MACRO_CONFIG_STR(Gfx3DTextureAnalysisRenderer, gfx_3d_texture_analysis_renderer, MACRO_CONFIG_STR(Gfx3DTextureAnalysisVersion, gfx_3d_texture_analysis_version, 128, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The version on which the analysis was performed") MACRO_CONFIG_STR(GfxGpuName, gfx_gpu_name, 256, "auto", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The GPU's name, which will be selected by the backend. (if supported by the backend)") -#if !defined(CONF_ARCH_IA32) && !defined(CONF_PLATFORM_MACOS) +#if defined(CONF_PLATFORM_ANDROID) +MACRO_CONFIG_STR(GfxBackend, gfx_backend, 256, "GLES", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The backend to use (e.g. GLES or Vulkan)") +#elif !defined(CONF_ARCH_IA32) && !defined(CONF_PLATFORM_MACOS) MACRO_CONFIG_STR(GfxBackend, gfx_backend, 256, "Vulkan", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The backend to use (e.g. OpenGL or Vulkan)") #else MACRO_CONFIG_STR(GfxBackend, gfx_backend, 256, "OpenGL", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The backend to use (e.g. OpenGL or Vulkan)")