fix thread collision setSize() problem.. working on opengl on linux

This commit is contained in:
benfry
2008-09-02 21:57:12 +00:00
parent 48718f252a
commit 394747ced3
3 changed files with 32 additions and 18 deletions
-6
View File
@@ -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);
+12 -1
View File
@@ -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);
// }
@@ -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");
}