From d9c4962cede15b5bc4172cf71f204f4cee0abd3d Mon Sep 17 00:00:00 2001 From: codeanticode Date: Thu, 13 Aug 2015 11:18:03 -0400 Subject: [PATCH] enable layer FBO layer when no background is called, so there should be no need for surface hack. --- core/src/processing/opengl/PGL.java | 8 ++++++-- core/src/processing/opengl/PGraphicsOpenGL.java | 14 +++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java index 1d8b3d30f..0a46de823 100644 --- a/core/src/processing/opengl/PGL.java +++ b/core/src/processing/opengl/PGL.java @@ -80,7 +80,7 @@ public abstract class PGL { * See the code and comments involving this constant in * PGraphicsOpenGL.endDraw(). */ - protected static boolean SAVE_SURFACE_TO_PIXELS_HACK = true; + protected static boolean SAVE_SURFACE_TO_PIXELS_HACK = false; /** Enables/disables mipmap use. */ protected static boolean MIPMAPS_ENABLED = true; @@ -625,7 +625,7 @@ public abstract class PGL { IntBuffer labelTex; - protected void endDraw(boolean clear0, int windowColor) { + protected void endDraw(boolean clear, int windowColor) { if (fboLayerInUse) { syncBackTexture(); @@ -705,6 +705,8 @@ public abstract class PGL { int temp = frontTex; frontTex = backTex; backTex = temp; + } else if (!clear && pg.parent.frameCount == 1) { + requestFBOLayer(); } } @@ -754,6 +756,8 @@ public abstract class PGL { String ext = getString(EXTENSIONS); float scale = pg.getPixelScale(); + System.err.println("creating fbo layer"); + if (-1 < ext.indexOf("texture_non_power_of_two")) { fboWidth = (int)(scale * pg.width); fboHeight = (int)(scale * pg.height); diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index b0c61414d..d6da0c2b2 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -1999,26 +1999,18 @@ public class PGraphicsOpenGL extends PGraphics { @Override public void beginDraw() { - if (primaryGraphics) { -// if (initialized) { -// if (sized) pgl.reinitSurface(); -// if (parent.canDraw()) pgl.requestDraw(); -// } else { -// initPrimary(); -// } + report("top beginDraw()"); + if (primaryGraphics) { if (!initialized) { initPrimary(); } - setCurrentPG(this); } else { pgl.getGL(getPrimaryPGL()); getPrimaryPG().setCurrentPG(this); } - report("top beginDraw()"); - if (!checkGLThread()) { return; } @@ -6879,7 +6871,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void endOnscreenDraw() { - pgl.endDraw(clearColorBuffer0, parent.sketchWindowColor()); + pgl.endDraw(clearColorBuffer, parent.sketchWindowColor()); }