diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java index 731164e69..47747b2b7 100644 --- a/core/src/processing/opengl/PGL.java +++ b/core/src/processing/opengl/PGL.java @@ -761,7 +761,7 @@ public abstract class PGL { int temp = frontTex; frontTex = backTex; backTex = temp; - } else if (!clear && pg.parent.frameCount == 1) { + } else if (!clear && 0 < pg.parent.frameCount || !pg.parent.isLooping()) { requestFBOLayer(); } } @@ -884,18 +884,32 @@ public abstract class PGL { if (0 < pg.parent.frameCount) { // Copy the contents of the front and back screen buffers to the textures // of the FBO, so they are properly initialized. - bindFramebufferImpl(READ_FRAMEBUFFER, BACK); + if (pg.parent.isLooping()) { + bindFramebufferImpl(READ_FRAMEBUFFER, FRONT); + readBuffer(FRONT); + } else { + bindFramebufferImpl(READ_FRAMEBUFFER, BACK); + readBuffer(BACK); + } bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0)); framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0, TEXTURE_2D, glColorTex.get(backTex), 0); + drawBuffer(COLOR_ATTACHMENT0); blitFramebuffer(0, 0, fboWidth, fboHeight, 0, 0, fboWidth, fboHeight, COLOR_BUFFER_BIT, NEAREST); - bindFramebufferImpl(READ_FRAMEBUFFER, FRONT); + if (pg.parent.isLooping()) { + bindFramebufferImpl(READ_FRAMEBUFFER, BACK); + readBuffer(BACK); + } else { + bindFramebufferImpl(READ_FRAMEBUFFER, FRONT); + readBuffer(FRONT); + } bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0)); framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0, TEXTURE_2D, glColorTex.get(frontTex), 0); + drawBuffer(COLOR_ATTACHMENT0); blitFramebuffer(0, 0, fboWidth, fboHeight, 0, 0, fboWidth, fboHeight, COLOR_BUFFER_BIT, NEAREST); diff --git a/core/src/processing/opengl/PSurfaceJOGL.java b/core/src/processing/opengl/PSurfaceJOGL.java index aab346585..44046ac4b 100644 --- a/core/src/processing/opengl/PSurfaceJOGL.java +++ b/core/src/processing/opengl/PSurfaceJOGL.java @@ -692,8 +692,12 @@ public class PSurfaceJOGL implements PSurface { class DrawListener implements GLEventListener { public void display(GLAutoDrawable drawable) { pgl.getGL(drawable); -// System.out.println(" - " + sketch.frameCount); + int pframeCount = sketch.frameCount; sketch.handleDraw(); + if (pframeCount == sketch.frameCount) { + pgl.beginDraw(false); + pgl.endDraw(false, sketch.sketchWindowColor()); + } if (sketch.frameCount == 1) { requestFocus();