@@ -308,6 +308,14 @@ public class PApplet extends Object implements ActivityAPI, PConstants {
308308
309309 protected boolean looping ;
310310
311+ // This auxiliary variable is used to implement a little hack that fixes
312+ // https://github.com/processing/processing-android/issues/147
313+ // on older devices where the last frame cannot be maintained after ending
314+ // the rendering in GL. The trick consists in running one more frame after the
315+ // noLoop() call, which ensures that the FBO layer is properly initialized
316+ // and drawn with the contents of the previous frame.
317+ protected boolean requestedNoLoop = false ;
318+
311319 /** flag set to true when a redraw is asked for by the user */
312320 protected boolean redraw ;
313321
@@ -1779,22 +1787,27 @@ public void handleDraw() {
17791787 }
17801788
17811789 insideDraw = true ;
1782- g . beginDraw ();
1790+
17831791// if (recorder != null) {
17841792// recorder.beginDraw();
17851793// }
17861794
17871795 if (requestedNoLoop ) {
1788- // noLoop() was called in the previous frame, with a GL renderer, but now
1796+ // noLoop() was called sometime in the previous frame with a GL renderer, but only now
17891797 // we are sure that the frame is properly displayed.
17901798 looping = false ;
1791- requestedNoLoop = false ;
1792- // We are done, we only need to finish the frame and exit.
1799+ // Perform a full frame draw, to ensure that the previous frame is properly displayed (see
1800+ // comment in the declaration of requestedNoLoop).
1801+ g .beginDraw ();
17931802 g .endDraw ();
1803+ requestedNoLoop = false ;
17941804 insideDraw = false ;
17951805 return ;
17961806 }
17971807
1808+ g .beginDraw ();
1809+
1810+
17981811 long now = System .nanoTime ();
17991812
18001813 if (frameCount == 0 ) {
@@ -1878,14 +1891,6 @@ synchronized public void loop() {
18781891 }
18791892
18801893
1881- // This auxiliary variable is used to implement a little hack that fixes
1882- // https://github.com/processing/processing-android/issues/147
1883- // on older devices where the last frame cannot be maintained after ending
1884- // the rendering in GL. The trick consists in running one more frame after the
1885- // noLoop() call, which ensures that the FBO layer is properly initialized
1886- // and drawn with the contents of the previous frame.
1887- private boolean requestedNoLoop = false ;
1888-
18891894 synchronized public void noLoop () {
18901895 if (looping ) {
18911896 if (g instanceof PGraphicsOpenGL ) {
0 commit comments