diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 129a3516b..45e5a2482 100755 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -10234,6 +10234,7 @@ public class PApplet extends Applet if (!newBounds.equals(oldBounds)) { // the ComponentListener in PApplet will handle calling size() setBounds(newBounds); + revalidate(); // let the layout manager do its work } } } diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java index aad1a8aaf..4f91aa09b 100644 --- a/core/src/processing/opengl/PGL.java +++ b/core/src/processing/opengl/PGL.java @@ -328,6 +328,9 @@ public abstract class PGL { protected abstract void initSurface(int antialias); + protected abstract void reinitSurface(); + + protected abstract void registerListeners(); @@ -2215,6 +2218,7 @@ public abstract class PGL { public static int SRC_ALPHA_SATURATE; public static int SCISSOR_TEST; + public static int STENCIL_TEST; public static int DEPTH_TEST; public static int DEPTH_WRITEMASK; public static int ALPHA_TEST; diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index f77dadb29..bb584f745 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -596,22 +596,6 @@ public class PGraphicsOpenGL extends PGraphics { width = iwidth; height = iheight; - allocate(); - reapplySettings(); - - // init perspective projection based on new dimensions - cameraFOV = 60 * DEG_TO_RAD; // at least for now - cameraX = width / 2.0f; - cameraY = height / 2.0f; - cameraZ = cameraY / ((float) Math.tan(cameraFOV / 2.0f)); - cameraNear = cameraZ / 10.0f; - cameraFar = cameraZ * 10.0f; - cameraAspect = (float) width / (float) height; - - // Forces a restart of OpenGL so the canvas has the right size. - restartPGL(); - - // set this flag so that beginDraw() will do an update to the camera. sized = true; } @@ -1621,6 +1605,8 @@ public class PGraphicsOpenGL extends PGraphics { public void requestDraw() { if (primarySurface) { if (initialized) { + if (sized) reinitPrimary(); + pgl.requestDraw(); } else { initPrimary(); @@ -6002,6 +5988,27 @@ public class PGraphicsOpenGL extends PGraphics { } + protected void reinitPrimary() { + allocate(); + + // init perspective projection based on new dimensions + cameraFOV = 60 * DEG_TO_RAD; // at least for now + cameraX = width / 2.0f; + cameraY = height / 2.0f; + cameraZ = cameraY / ((float) Math.tan(cameraFOV / 2.0f)); + cameraNear = cameraZ / 10.0f; + cameraFar = cameraZ * 10.0f; + cameraAspect = (float) width / (float) height; + + // Forces a restart of OpenGL so the canvas has the right size. + // restartPGL(); + + // System.out.println("hasbeenSized"); + + pgl.reinitSurface(); + } + + protected void beginOnscreenDraw() { pgl.beginDraw(clearColorBuffer); @@ -6177,6 +6184,8 @@ public class PGraphicsOpenGL extends PGraphics { pgl.disable(PGL.POLYGON_SMOOTH); if (sized) { + //reapplySettings(); + // To avoid having garbage in the screen after a resize, // in the case background is not called in draw(). background(backgroundColor); diff --git a/core/src/processing/opengl/PJOGL.java b/core/src/processing/opengl/PJOGL.java index 4418d67f0..24079c734 100644 --- a/core/src/processing/opengl/PJOGL.java +++ b/core/src/processing/opengl/PJOGL.java @@ -313,6 +313,15 @@ public class PJOGL extends PGL { } + @Override + protected void reinitSurface() { + sinkFBO = backFBO = frontFBO = null; + fboLayerCreated = false; + fboLayerInUse = false; + firstFrame = true; + } + + @Override protected void registerListeners() { if (WINDOW_TOOLKIT == AWT) { @@ -777,7 +786,7 @@ public class PJOGL extends PGL { @Override public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) { - getGL(glDrawable); + //getGL(glDrawable); } private void getGL(GLAutoDrawable glDrawable) { @@ -1343,6 +1352,7 @@ public class PJOGL extends PGL { SRC_ALPHA_SATURATE = GL.GL_SRC_ALPHA_SATURATE; SCISSOR_TEST = GL.GL_SCISSOR_TEST; + STENCIL_TEST = GL.GL_STENCIL_TEST; DEPTH_TEST = GL.GL_DEPTH_TEST; DEPTH_WRITEMASK = GL.GL_DEPTH_WRITEMASK; ALPHA_TEST = GL2ES1.GL_ALPHA_TEST; diff --git a/experimental/.gitignore b/experimental/.gitignore new file mode 100644 index 000000000..c5e82d745 --- /dev/null +++ b/experimental/.gitignore @@ -0,0 +1 @@ +bin \ No newline at end of file