1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Merge pull request #39004 from nekomatata/android-reset-surface

Proper surface reset when resuming app on Android
This commit is contained in:
Rémi Verschelde
2020-05-24 22:31:03 +02:00
committed by GitHub
7 changed files with 43 additions and 17 deletions

View File

@@ -66,11 +66,12 @@ public class GodotLib {
/**
* Invoked on the GL thread when the underlying Android surface has changed size.
* @param width
* @param height
* @param p_surface
* @param p_width
* @param p_height
* @see android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(GL10, int, int)
*/
public static native void resize(int width, int height);
public static native void resize(Surface p_surface, int p_width, int p_height);
/**
* Invoked on the render thread when the underlying Android surface is created or recreated.

View File

@@ -64,7 +64,7 @@ class GodotRenderer implements GLSurfaceView.Renderer {
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
GodotLib.resize(width, height);
GodotLib.resize(null, width, height);
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
plugin.onGLSurfaceChanged(gl, width, height);
}

View File

@@ -59,9 +59,7 @@ internal class VkRenderer {
* Called when the surface is created and signals the beginning of rendering.
*/
fun onVkSurfaceCreated(surface: Surface) {
// TODO: properly implement surface re-creation:
// GodotLib.newcontext should be called here once it's done.
//GodotLib.newcontext(surface, false)
GodotLib.newcontext(surface, false)
for (plugin in pluginRegistry.getAllPlugins()) {
plugin.onVkSurfaceCreated(surface)
@@ -72,12 +70,7 @@ internal class VkRenderer {
* Called after the surface is created and whenever its size changes.
*/
fun onVkSurfaceChanged(surface: Surface, width: Int, height: Int) {
GodotLib.resize(width, height)
// TODO: properly implement surface re-creation:
// Update the native renderer instead of restarting the app.
// GodotLib.newcontext should not be called here once it's done.
GodotLib.newcontext(surface, false)
GodotLib.resize(surface, width, height)
for (plugin in pluginRegistry.getAllPlugins()) {
plugin.onVkSurfaceChanged(surface, width, height)