summaryrefslogtreecommitdiffstats
path: root/platform/android
diff options
context:
space:
mode:
authorSummersay415 <summersay415@gmail.com>2024-10-28 13:08:07 +0700
committerSummersay415 <summersay415@gmail.com>2024-10-28 22:57:19 +0700
commit6d14cd6ff96f74199acea2ad449ec2e1d2dcceab (patch)
tree4d068f9a0a16f66231a7d2b7a7d3b21fd1a5f65d /platform/android
parenta3080477ac0421aef24ca0916c40559abbf4846b (diff)
downloadredot-engine-6d14cd6ff96f74199acea2ad449ec2e1d2dcceab.tar.gz
Fix fallbacks to OpenGL
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/display_server_android.cpp19
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.kt18
2 files changed, 27 insertions, 10 deletions
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index e3ee1dd631..c269f4d167 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -604,12 +604,6 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
native_menu = memnew(NativeMenu);
-#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
- RasterizerGLES3::make_current(false);
- }
-#endif
-
#if defined(RD_ENABLED)
rendering_context = nullptr;
rendering_device = nullptr;
@@ -624,19 +618,24 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
if (rendering_context->initialize() != OK) {
memdelete(rendering_context);
rendering_context = nullptr;
+#if defined(GLES3_ENABLED)
bool fallback_to_opengl3 = GLOBAL_GET("rendering/rendering_device/fallback_to_opengl3");
if (fallback_to_opengl3 && rendering_driver != "opengl3") {
WARN_PRINT("Your device seem not to support Vulkan, switching to OpenGL 3.");
rendering_driver = "opengl3";
OS::get_singleton()->set_current_rendering_method("gl_compatibility");
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
- } else {
+ } else
+#endif
+ {
ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver));
r_error = ERR_UNAVAILABLE;
return;
}
}
+ }
+ if (rendering_context) {
union {
#ifdef VULKAN_ENABLED
RenderingContextDriverVulkanAndroid::WindowPlatformData vulkan;
@@ -676,6 +675,12 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
}
#endif
+#if defined(GLES3_ENABLED)
+ if (rendering_driver == "opengl3") {
+ RasterizerGLES3::make_current(false);
+ }
+#endif
+
Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
r_error = OK;
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
index 567b134234..61c027d3ee 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
@@ -477,12 +477,17 @@ class Godot(private val context: Context) {
// ...add to FrameLayout
containerLayout?.addView(editText)
renderView = if (usesVulkan()) {
- if (!meetsVulkanRequirements(activity.packageManager)) {
+ if (meetsVulkanRequirements(activity.packageManager)) {
+ GodotVulkanRenderView(host, this, godotInputHandler)
+ } else if (canFallbackToOpenGL()) {
+ // Fallback to OpenGl.
+ GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl)
+ } else {
throw IllegalStateException(activity.getString(R.string.error_missing_vulkan_requirements_message))
}
- GodotVulkanRenderView(host, this, godotInputHandler)
+
} else {
- // Fallback to openGl
+ // Fallback to OpenGl.
GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl)
}
@@ -817,6 +822,13 @@ class Godot(private val context: Context) {
}
/**
+ * Returns true if can fallback to OpenGL.
+ */
+ private fun canFallbackToOpenGL(): Boolean {
+ return java.lang.Boolean.parseBoolean(GodotLib.getGlobal("rendering/rendering_device/fallback_to_opengl3"))
+ }
+
+ /**
* Returns true if the device meets the base requirements for Vulkan support, false otherwise.
*/
private fun meetsVulkanRequirements(packageManager: PackageManager?): Boolean {