From 6d14cd6ff96f74199acea2ad449ec2e1d2dcceab Mon Sep 17 00:00:00 2001 From: Summersay415 Date: Mon, 28 Oct 2024 13:08:07 +0700 Subject: Fix fallbacks to OpenGL --- .../java/lib/src/org/godotengine/godot/Godot.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'platform/android/java') 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) } @@ -816,6 +821,13 @@ class Godot(private val context: Context) { return ("forward_plus" == renderer || "mobile" == renderer) && "vulkan" == renderingDevice } + /** + * 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. */ -- cgit v1.2.3