diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 234cc24d9..47eb244a4 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -6613,12 +6613,6 @@ public class PApplet extends Applet } - public void setSize(int iwidth, int iheight) { - if (recorder != null) recorder.setSize(iwidth, iheight); - g.setSize(iwidth, iheight); - } - - public void hint(int which) { if (recorder != null) recorder.hint(which); g.hint(which); diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 8a6022188..1d2f6811d 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -617,7 +617,18 @@ public abstract class PGraphics extends PImage implements PConstants { } - public void setSize(int iwidth, int iheight) { + /** + * The final step in setting up a renderer, set its size of this renderer. + * This was formerly handled by the constructor, but instead it's been broken + * out so that setParent/setPrimary/setPath can be handled differently. + * + * Important that this is ignored by preproc.pl because otherwise it will + * override setSize() in PApplet/Applet/Component, which will 1) not call + * super.setSize(), and 2) will cause the renderer to be resized from the + * event thread (EDT), causing a nasty crash as it collides with the + * animation thread. + */ + public void setSize(int iwidth, int iheight) { // ignore resizeSurface(iwidth, iheight); // } diff --git a/opengl/src/processing/opengl/PGraphicsOpenGL.java b/opengl/src/processing/opengl/PGraphicsOpenGL.java index 709038d9c..6a3919df5 100644 --- a/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -145,21 +145,24 @@ public class PGraphicsOpenGL extends PGraphics3D { capabilities.setSampleBuffers(true); capabilities.setNumSamples(4); } + // get a rendering surface and a context for this canvas GLDrawableFactory factory = GLDrawableFactory.getFactory(); - GraphicsConfiguration pconfig = parent.getGraphicsConfiguration(); - System.out.println("parent config is " + pconfig); - -// GraphicsDevice device = config.getDevice(); - //AbstractGraphicsDevice agd = new AbstractGraphicsDevice(device); - //AbstractGraphicsConfiguration agc = factory.chooseGraphicsConfiguration(capabilities, null, null); - - AWTGraphicsConfiguration agc = (AWTGraphicsConfiguration) + if (PApplet.platform == PConstants.LINUX) { + GraphicsConfiguration pconfig = parent.getGraphicsConfiguration(); + System.out.println("parent config is " + pconfig); + + // GraphicsDevice device = config.getDevice(); + //AbstractGraphicsDevice agd = new AbstractGraphicsDevice(device); + //AbstractGraphicsConfiguration agc = factory.chooseGraphicsConfiguration(capabilities, null, null); + + AWTGraphicsConfiguration agc = (AWTGraphicsConfiguration) factory.chooseGraphicsConfiguration(capabilities, null, null); - GraphicsConfiguration config = agc.getGraphicsConfiguration(); - System.out.println("agc config is " + config); - + GraphicsConfiguration config = agc.getGraphicsConfiguration(); + System.out.println("agc config is " + config); + } + drawable = factory.getGLDrawable(parent, capabilities, null); context = drawable.createContext(null); @@ -1797,8 +1800,14 @@ public class PGraphicsOpenGL extends PGraphics3D { protected void fillFromCalc() { super.fillFromCalc(); calcColorBuffer(); +// String nom = Thread.currentThread().getName(); +// System.out.println("fill in " + nom); +// if (!nom.equals("Animation Thread")) { +// new Exception().printStackTrace(); +// } gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, colorBuffer); +// System.out.println("fill out"); }