File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -2145,6 +2145,16 @@ public void handleDraw() {
2145
2145
2146
2146
g .beginDraw ();
2147
2147
2148
+ if (requestedNoLoop ) {
2149
+ // noLoop() was called in the previous frame, with a GL renderer, but now
2150
+ // we are sure that the frame is properly displayed.
2151
+ looping = false ;
2152
+ requestedNoLoop = false ;
2153
+ // We are done, we only need to finish the frame and exit.
2154
+ g .endDraw ();
2155
+ return ;
2156
+ }
2157
+
2148
2158
long now = System .nanoTime ();
2149
2159
2150
2160
if (frameCount == 0 ) {
@@ -2246,9 +2256,21 @@ synchronized public void loop() {
2246
2256
}
2247
2257
2248
2258
2259
+ // This auxiliary variable is used to implement a little hack that fixes
2260
+ // https://github.com/processing/processing-android/issues/147
2261
+ // on older devices where the last frame cannot be maintained after ending
2262
+ // the rendering in GL. The trick consists in running one more frame after the
2263
+ // noLoop() call, which ensures that the FBO layer is properly initialized
2264
+ // and drawn with the contents of the previous frame.
2265
+ private boolean requestedNoLoop = false ;
2266
+
2249
2267
synchronized public void noLoop () {
2250
2268
if (looping ) {
2251
- looping = false ;
2269
+ if (g instanceof PGraphicsOpenGL ) {
2270
+ requestedNoLoop = true ;
2271
+ } else {
2272
+ looping = false ;
2273
+ }
2252
2274
}
2253
2275
}
2254
2276
Original file line number Diff line number Diff line change @@ -942,6 +942,8 @@ protected void saveFirstFrame() {
942
942
943
943
944
944
protected void restoreFirstFrame () {
945
+ if (firstFrame == null ) return ;
946
+
945
947
IntBuffer tex = allocateIntBuffer (1 );
946
948
genTextures (1 , tex );
947
949
You can’t perform that action at this time.
0 commit comments