diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index b4dd3e903..c9a1d9564 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -54,6 +54,12 @@ public abstract class PGraphics extends PImage implements PConstants { /// true if defaults() has been called a first time boolean defaultsInited; + /// true if in-between beginDraw() and endDraw() + boolean insideDraw; + + /// true if in the midst of resize (no drawing can take place) + boolean insideResize; + // ........................................................ // specifics for java memoryimagesource @@ -546,30 +552,26 @@ public abstract class PGraphics extends PImage implements PConstants { // FRAME - /** - * Former function, now called beginDraw. - * @deprecated - */ - /* - public void beginFrame() { // ignore - System.err.println("beginFrame() is now beginDraw(), please use that instead"); - beginDraw(); + protected void insideResizeWait() { + while (insideResize) { + //System.out.println("waiting"); + try { + Thread.sleep(5); + } catch (InterruptedException e) { } + } } - */ - - /** - * Former function, now called endDraw. - * @deprecated - */ - /* - public void endFrame() { // ignore - System.err.println("endFrame() is now endDraw(), please use that instead"); - endDraw(); + + protected void insideDrawWait() { + while (insideDraw) { + //System.out.println("waiting"); + try { + Thread.sleep(5); + } catch (InterruptedException e) { } + } } - */ - - + + /** * Prepares the PGraphics for drawing. *
@@ -3693,15 +3695,9 @@ public abstract class PGraphics extends PImage implements PConstants { /** - * Clears pixel buffer. - *- * Subclasses (PGraphics3) will also clear the - * stencil and zbuffer if they exist. + * Clear the pixel buffer. */ protected void clear() { - for (int i = 0; i < pixelCount; i++) { - pixels[i] = backgroundColor; - } } diff --git a/core/src/processing/core/PGraphics2D.java b/core/src/processing/core/PGraphics2D.java index 057875f5a..929f09e79 100644 --- a/core/src/processing/core/PGraphics2D.java +++ b/core/src/processing/core/PGraphics2D.java @@ -1591,6 +1591,22 @@ public class PGraphics2D extends PGraphics { } + + ////////////////////////////////////////////////////////////// + + // BACKGROUND AND FRIENDS + + + /** + * Clear the pixel buffer. + */ + protected void clear() { + for (int i = 0; i < pixelCount; i++) { + pixels[i] = backgroundColor; + } + } + + ////////////////////////////////////////////////////////////// diff --git a/core/src/processing/core/PGraphics3D.java b/core/src/processing/core/PGraphics3D.java index 95fac2c90..aac0ae427 100644 --- a/core/src/processing/core/PGraphics3D.java +++ b/core/src/processing/core/PGraphics3D.java @@ -218,8 +218,17 @@ public class PGraphics3D extends PGraphics { * Note that this will nuke any cameraMode() settings. */ public void resize(int iwidth, int iheight) { // ignore - //System.out.println("PGraphics3 resize"); - + insideDrawWait(); + /* + while (insideDraw) { + //System.out.println("waiting"); + try { + Thread.sleep(5); + } catch (InterruptedException e) { } + } + */ + insideResize = true; + width = iwidth; height = iheight; width1 = width - 1; @@ -278,11 +287,14 @@ public class PGraphics3D extends PGraphics { // own projection, they'll need to fix it after resize anyway. // this helps the people who haven't set up their own projection. perspective(); + + insideResize = false; // ok to draw again } protected void allocate() { - //System.out.println("allocating for " + width + " " + height); + //System.out.println(this + " allocating for " + width + " " + height); + //new Exception().printStackTrace(); pixelCount = width * height; pixels = new int[pixelCount]; @@ -305,10 +317,15 @@ public class PGraphics3D extends PGraphics { line = new PLine(this); triangle = new PTriangle(this); + + //System.out.println(this + " done allocating"); } public void beginDraw() { + insideResizeWait(); + insideDraw = true; + // need to call defaults(), but can only be done when it's ok // to draw (i.e. for opengl, no drawing can be done outside // beginDraw/endDraw). @@ -368,6 +385,9 @@ public class PGraphics3D extends PGraphics { // mark pixels as having been updated, so that they'll work properly // when this PGraphics is drawn using image(). endPixels(); + + //System.out.println(this + " end draw"); + insideDraw = false; } @@ -3578,8 +3598,7 @@ public class PGraphics3D extends PGraphics { /** - * Clears pixel buffer. - *
+ * Clear pixel buffer. * With P3D and OPENGL, this also clears the stencil and zbuffer. */ public void clear() { diff --git a/core/todo.txt b/core/todo.txt index 4460bd807..6ab74c791 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -25,6 +25,20 @@ X update jogl to latest beta 5 _ might fix blank screen issues on linux: _ http://dev.processing.org/bugs/show_bug.cgi?id=367 X make framerate into frameRate (to match frameCount) +X AIOOBE in P3D during defaults/background/clear +X PGraphics.clear() problem from workbench and malware stuff +X had to put synchronized onto draw and size() +X actually it'll work if it's only on size() +X the sync on the mac hangs an applet running by itself +X even though it seems to be ok for a component +X thread sync problem with allocation +X http://dev.processing.org/bugs/show_bug.cgi?id=369 + +_ size of sketch different in setup() and draw() on linux +_ make sure that the sketch isn't being sized based on bad insets +_ http://dev.processing.org/bugs/show_bug.cgi?id=341 + +_ add begin/end/alloc waits to PGraphicsJava2D, PGraphicsOpenGL, and PGraphics3D fixed in 0115 / quicktime 7.1 X color values on camera input flipped on intel macs @@ -39,12 +53,15 @@ o right now the camera doesn't get set up unless you call depth() o box and sphere are broken in gl o what should the update image function be called? +_ set default frameRate cap at 60? + _ color(0, 0, 0, 0) produces black _ although fill(0, 0, 0, 0) does the right thing _ also, rgb255 not getting set _ http://dev.processing.org/bugs/show_bug.cgi?id=382 _ revision 115 may be saving raw files as TIFF format +_ may be a bug specific to java 1.5 _ http://dev.processing.org/bugs/show_bug.cgi?id=378 things before 1.0 @@ -64,14 +81,6 @@ _ otherwise the end will look like it's time to update _ which may not actually be the case _ i.e. calling filter() inside begin/end block -_ PGraphics.clear() problem from workbench and malware stuff -_ had to put synchronized onto draw and size() -_ actually it'll work if it's only on size() -_ the sync on the mac hangs an applet running by itself -_ even though it seems to be ok for a component -_ AIOOBE in P3D during defaults/background/clear -_ thread sync problem with allocation - _ remove image(filename) and textFont(filename) et al. _ hint(DISABLE_NATIVE_FONTS) to disable the built-in stuff?