From 466d6794dfef32af1d8b2d75258a6524a6ef8973 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Fri, 27 May 2011 01:07:13 +0000 Subject: [PATCH] Same for OPENGL --- .../processing/opengl/PGraphicsOpenGL.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index 53a2391fd..c9fcfbdba 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -103,6 +103,9 @@ public class PGraphicsOpenGL extends PGraphics3D { /// IntBuffer to go with the pixels[] array protected IntBuffer pixelBuffer; + + /** Used to detect the occurrence of a frame resize event. */ + protected boolean resized = false; /** * Set to true if the host system is big endian (PowerPC, MIPS, SPARC), @@ -237,7 +240,10 @@ public class PGraphicsOpenGL extends PGraphics3D { //public void setPath(String path) // PGraphics - //public void setSize(int iwidth, int iheight) // PGraphics3D + public void setSize(int iwidth, int iheight) { + resized = (0 < width && width != iwidth) || (0 < height && height != iwidth); + super.setSize(iwidth, iheight); + } /** @@ -291,9 +297,9 @@ public class PGraphicsOpenGL extends PGraphics3D { } else { // The following three lines are a fix for Bug #1176 // http://dev.processing.org/bugs/show_bug.cgi?id=1176 - context.destroy(); - context = drawable.createContext(null); - gl = context.getGL(); + //context.destroy(); + //context = drawable.createContext(null); + //gl = context.getGL(); reapplySettings(); } } @@ -381,6 +387,14 @@ public class PGraphicsOpenGL extends PGraphics3D { for (int i = 0; i < MAX_LIGHTS; i++) { gl.glDisable(GL.GL_LIGHT0 + i); } + + gl.glViewport(0, 0, width, height); + if (resized) { + // To avoid having garbage in the screen after a resize, + // in the case background is not called in draw(). + background(0); + resized = false; + } updateProjection();