Skip to content

Commit 78626a5

Browse files
committed
trying different blitting order
1 parent fef2752 commit 78626a5

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

core/src/processing/opengl/PGL.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ protected void endDraw(boolean clear, int windowColor) {
761761
int temp = frontTex;
762762
frontTex = backTex;
763763
backTex = temp;
764-
} else if (!clear && pg.parent.frameCount == 1) {
764+
} else if (!clear && 0 < pg.parent.frameCount || !pg.parent.isLooping()) {
765765
requestFBOLayer();
766766
}
767767
}
@@ -884,18 +884,32 @@ private void createFBOLayer() {
884884
if (0 < pg.parent.frameCount) {
885885
// Copy the contents of the front and back screen buffers to the textures
886886
// of the FBO, so they are properly initialized.
887-
bindFramebufferImpl(READ_FRAMEBUFFER, BACK);
887+
if (pg.parent.isLooping()) {
888+
bindFramebufferImpl(READ_FRAMEBUFFER, FRONT);
889+
readBuffer(FRONT);
890+
} else {
891+
bindFramebufferImpl(READ_FRAMEBUFFER, BACK);
892+
readBuffer(BACK);
893+
}
888894
bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0));
889895
framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0,
890896
TEXTURE_2D, glColorTex.get(backTex), 0);
897+
drawBuffer(COLOR_ATTACHMENT0);
891898
blitFramebuffer(0, 0, fboWidth, fboHeight,
892899
0, 0, fboWidth, fboHeight,
893900
COLOR_BUFFER_BIT, NEAREST);
894901

895-
bindFramebufferImpl(READ_FRAMEBUFFER, FRONT);
902+
if (pg.parent.isLooping()) {
903+
bindFramebufferImpl(READ_FRAMEBUFFER, BACK);
904+
readBuffer(BACK);
905+
} else {
906+
bindFramebufferImpl(READ_FRAMEBUFFER, FRONT);
907+
readBuffer(FRONT);
908+
}
896909
bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0));
897910
framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0,
898911
TEXTURE_2D, glColorTex.get(frontTex), 0);
912+
drawBuffer(COLOR_ATTACHMENT0);
899913
blitFramebuffer(0, 0, fboWidth, fboHeight,
900914
0, 0, fboWidth, fboHeight,
901915
COLOR_BUFFER_BIT, NEAREST);

core/src/processing/opengl/PSurfaceJOGL.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,12 @@ public void requestFocus() {
692692
class DrawListener implements GLEventListener {
693693
public void display(GLAutoDrawable drawable) {
694694
pgl.getGL(drawable);
695-
// System.out.println(" - " + sketch.frameCount);
695+
int pframeCount = sketch.frameCount;
696696
sketch.handleDraw();
697+
if (pframeCount == sketch.frameCount) {
698+
pgl.beginDraw(false);
699+
pgl.endDraw(false, sketch.sketchWindowColor());
700+
}
697701

698702
if (sketch.frameCount == 1) {
699703
requestFocus();

0 commit comments

Comments
 (0)