1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Window transparency support on Android

Implements per-pixel transparency feature on Android.
Allows plugins to do specific rendering and render godot UI on top
(useful for camera support with drawing on top).
This commit is contained in:
PouleyKetchoupp
2021-08-06 17:10:28 -07:00
parent 1cbb1f2796
commit 52fdb4ece9
7 changed files with 28 additions and 7 deletions

View File

@@ -130,6 +130,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
private boolean use_32_bits = false;
private boolean use_immersive = false;
private boolean use_debug_opengl = false;
private boolean translucent = false;
private boolean mStatePaused;
private boolean activityResumed;
private int mState;
@@ -357,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);
mView = new GodotView(activity, this, xrMode, use_gl3, use_32_bits, use_debug_opengl, translucent);
containerLayout.addView(mView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
edittext.setView(mView);
io.setEdit(edittext);
@@ -608,6 +609,8 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
use_32_bits = true;
} else if (command_line[i].equals("--debug_opengl")) {
use_debug_opengl = true;
} else if (command_line[i].equals("--translucent")) {
translucent = true;
} else if (command_line[i].equals("--use_immersive")) {
use_immersive = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // check if the application runs on an android 4.4+

View File

@@ -76,7 +76,7 @@ public class GodotView extends GLSurfaceView {
private final GodotRenderer godotRenderer;
public GodotView(Context context, Godot godot, XRMode xrMode, boolean p_use_gl3,
boolean p_use_32_bits, boolean p_use_debug_opengl) {
boolean p_use_32_bits, boolean p_use_debug_opengl, boolean p_translucent) {
super(context);
GLUtils.use_gl3 = p_use_gl3;
GLUtils.use_32 = p_use_32_bits;
@@ -86,7 +86,8 @@ public class GodotView extends GLSurfaceView {
this.inputHandler = new GodotInputHandler(this);
this.detector = new GestureDetector(context, new GodotGestureHandler(this));
this.godotRenderer = new GodotRenderer();
init(xrMode, false, 16, 0);
init(xrMode, p_translucent, 16, 0);
}
public void initInputDevices() {
@@ -139,6 +140,7 @@ public class GodotView extends GLSurfaceView {
* is interpreted as any 32-bit surface with alpha by SurfaceFlinger.
*/
if (translucent) {
this.setZOrderOnTop(true);
this.getHolder().setFormat(PixelFormat.TRANSLUCENT);
}