diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 9d56dbc15d..10ed9b3037 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1691,7 +1691,7 @@ void EditorExportPlatformAndroid::get_export_options(List *r_optio r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, "*.png"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_background_option, PROPERTY_HINT_FILE, "*.png"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true)); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/depth_buffer_bits", PROPERTY_HINT_ENUM, "16 bits,24 bits [default],32 bits"), 1)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/opengl_debug"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/xr_mode", PROPERTY_HINT_ENUM, "Regular,Oculus Mobile VR"), 0)); @@ -2530,9 +2530,10 @@ void EditorExportPlatformAndroid::get_command_line_flags(const Refget("graphics/32_bits_framebuffer"); - if (use_32_bit_framebuffer) { - command_line_strings.push_back("--use_depth_32"); + int depth_buffer_bits_index = p_preset->get("graphics/depth_buffer_bits"); + if (depth_buffer_bits_index >= 0 && depth_buffer_bits_index <= 2) { + int depth_buffer_bits = 16 + depth_buffer_bits_index * 8; + command_line_strings.push_back(vformat("--use_depth=%d", depth_buffer_bits)); } bool immersive = p_preset->get("screen/immersive_mode"); diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index e89e2cdea4..2f3ae3f120 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -127,7 +127,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC private Button mWiFiSettingsButton; private XRMode xrMode = XRMode.REGULAR; - private boolean use_32_bits = false; + private int depth_buffer_bits = 24; private boolean use_immersive = false; private boolean use_debug_opengl = false; private boolean translucent = false; @@ -358,7 +358,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC // ...add to FrameLayout containerLayout.addView(edittext); - mView = new GodotView(activity, this, xrMode, use_gl3, use_32_bits, use_debug_opengl, translucent); + mView = new GodotView(activity, this, xrMode, use_gl3, depth_buffer_bits, use_debug_opengl, translucent); containerLayout.addView(mView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); edittext.setView(mView); io.setEdit(edittext); @@ -621,8 +621,12 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC xrMode = XRMode.REGULAR; } else if (command_line[i].equals(XRMode.OVR.cmdLineArg)) { xrMode = XRMode.OVR; - } else if (command_line[i].equals("--use_depth_32")) { - use_32_bits = true; + } else if (command_line[i].startsWith("--use_depth=")) { + try { + depth_buffer_bits = Integer.parseInt(command_line[i].split("=")[1]); + } catch (Exception e) { + e.printStackTrace(); + } } else if (command_line[i].equals("--debug_opengl")) { use_debug_opengl = true; } else if (command_line[i].equals("--translucent")) { diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotView.java index 211b18e773..210943c968 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotView.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotView.java @@ -84,10 +84,10 @@ public class GodotView extends GLSurfaceView { private EGLContext eglSecondaryContext; public GodotView(Context context, Godot godot, XRMode xrMode, boolean p_use_gl3, - boolean p_use_32_bits, boolean p_use_debug_opengl, boolean p_translucent) { + int p_depth_buffer_bits, boolean p_use_debug_opengl, boolean p_translucent) { super(context); GLUtils.use_gl3 = p_use_gl3; - GLUtils.use_32 = p_use_32_bits; + GLUtils.depth_buffer_bits = p_depth_buffer_bits; GLUtils.use_debug_opengl = p_use_debug_opengl; this.godot = godot; @@ -163,17 +163,14 @@ public class GodotView extends GLSurfaceView { * below. */ - if (GLUtils.use_32) { - eglConfigChooser = translucent - ? new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, - new RegularConfigChooser(8, 8, 8, 8, 16, stencil)) - : new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, - new RegularConfigChooser(5, 6, 5, 0, 16, stencil)); - - } else { - eglConfigChooser = translucent - ? new RegularConfigChooser(8, 8, 8, 8, 16, stencil) - : new RegularConfigChooser(5, 6, 5, 0, 16, stencil); + eglConfigChooser = + new RegularFallbackConfigChooser(8, 8, 8, 8, 16, stencil, + new RegularConfigChooser(5, 6, 5, 0, 16, stencil)); + if (GLUtils.depth_buffer_bits >= 24) { + eglConfigChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, eglConfigChooser); + if (GLUtils.depth_buffer_bits >= 32) { + eglConfigChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 32, stencil, eglConfigChooser); + } } break; } diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java index 84a8d192e5..dbd815c2d3 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java +++ b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java @@ -45,7 +45,7 @@ public class GLUtils { public static final boolean DEBUG = false; public static boolean use_gl3 = false; - public static boolean use_32 = false; + public static int depth_buffer_bits; // No need to reiterate the default here public static boolean use_debug_opengl = false; private static final String[] ATTRIBUTES_NAMES = new String[] { diff --git a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java index e690c5b695..63c5381994 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java +++ b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java @@ -38,7 +38,7 @@ import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLDisplay; -/* Fallback if 32bit View is not supported*/ +/* Fallback if the requested configuration is not supported */ public class RegularFallbackConfigChooser extends RegularConfigChooser { private static final String TAG = RegularFallbackConfigChooser.class.getSimpleName(); @@ -55,7 +55,6 @@ public class RegularFallbackConfigChooser extends RegularConfigChooser { if (ec == null) { Log.w(TAG, "Trying ConfigChooser fallback"); ec = fallback.chooseConfig(egl, display, configs); - GLUtils.use_32 = false; } return ec; }