diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-11-09 11:55:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 11:55:26 +0100 |
commit | 8a15e404b24c4c7ea66a71da5197fdb61c00b854 (patch) | |
tree | 9c8f1f67f27e8809dd00081b475e5d658ff4cfcd /platform/android/java | |
parent | 9444a3f01d3a8c4f49ddf24e3acc65b399ee0609 (diff) | |
parent | 07adf1193d0278dab5ffbd073e19bdf97cb3507f (diff) |
Merge pull request #54463 from RandomShaper/fix_gl3_32bits
Diffstat (limited to 'platform/android/java')
7 files changed, 24 insertions, 24 deletions
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 d39ab30cda..d872d5ed8a 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -119,7 +119,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 mStatePaused; @@ -266,7 +266,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC if (videoDriver.equals("vulkan")) { mRenderView = new GodotVulkanRenderView(activity, this); } else { - mRenderView = new GodotGLRenderView(activity, this, xrMode, use_32_bits, + mRenderView = new GodotGLRenderView(activity, this, xrMode, depth_buffer_bits, use_debug_opengl); } @@ -506,8 +506,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("--use_immersive")) { diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java index 32aad8dc4f..8b77302491 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java @@ -78,10 +78,10 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView private final GodotRenderer godotRenderer; private PointerIcon pointerIcon; - public GodotGLRenderView(Context context, Godot godot, XRMode xrMode, boolean p_use_32_bits, + public GodotGLRenderView(Context context, Godot godot, XRMode xrMode, int p_depth_buffer_bits, boolean p_use_debug_opengl) { super(context); - 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; @@ -209,18 +209,16 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView * below. */ - if (GLUtils.use_32) { - setEGLConfigChooser(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 { - setEGLConfigChooser(translucent - ? new RegularConfigChooser(8, 8, 8, 8, 16, stencil) - : new RegularConfigChooser(5, 6, 5, 0, 16, stencil)); + RegularConfigChooser configChooser = + new RegularFallbackConfigChooser(8, 8, 8, 8, 16, stencil, + new RegularConfigChooser(5, 6, 5, 0, 16, stencil)); + if (GLUtils.depth_buffer_bits >= 24) { + configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, configChooser); + if (GLUtils.depth_buffer_bits >= 32) { + configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 32, stencil, configChooser); + } } + setEGLConfigChooser(configChooser); break; } diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java index 95870acda1..a23d030d4c 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java @@ -75,9 +75,8 @@ public class GodotLib { /** * Invoked on the render thread when the underlying Android surface is created or recreated. * @param p_surface - * @param p_32_bits */ - public static native void newcontext(Surface p_surface, boolean p_32_bits); + public static native void newcontext(Surface p_surface); /** * Forward {@link Activity#onBackPressed()} event from the main thread to the GL thread. diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java index 878a119c5c..12e452fc99 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java @@ -70,7 +70,7 @@ class GodotRenderer implements GLSurfaceView.Renderer { } public void onSurfaceCreated(GL10 gl, EGLConfig config) { - GodotLib.newcontext(null, GLUtils.use_32); + GodotLib.newcontext(null); for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) { plugin.onGLSurfaceCreated(gl, config); } 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 19588f8465..0d581785ab 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 @@ -44,7 +44,7 @@ public class GLUtils { public static final boolean DEBUG = 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/vulkan/VkRenderer.kt b/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt index a35f6ec5a7..b13f9bfeab 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt @@ -58,7 +58,7 @@ internal class VkRenderer { * Called when the surface is created and signals the beginning of rendering. */ fun onVkSurfaceCreated(surface: Surface) { - GodotLib.newcontext(surface, false) + GodotLib.newcontext(surface) for (plugin in pluginRegistry.getAllPlugins()) { plugin.onVkSurfaceCreated(surface) 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; } |