From 0bba314042ab3ac72d623b860ce1deb746ecbb5b Mon Sep 17 00:00:00 2001 From: benfry Date: Tue, 2 Sep 2008 22:51:43 +0000 Subject: [PATCH] fix fo bug #891 and #909, does pack() before showing --- core/src/processing/core/PApplet.java | 7 +++ .../processing/opengl/PGraphicsOpenGL.java | 44 ++----------------- 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 47eb244a4..6068c15f7 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -6340,6 +6340,13 @@ public class PApplet extends Applet applet.args = PApplet.subset(args, 1); applet.external = external; + // For 0149, moving this code (up to the pack() method) before init(). + // For OpenGL (and perhaps other renderers in the future), a peer is + // needed before a GLDrawable can be created. So pack() needs to be + // called on the Frame before applet.init(), which itself calls size(), + // and launches the Thread that will kick off setup(). + // http://dev.processing.org/bugs/show_bug.cgi?id=891 + // http://dev.processing.org/bugs/show_bug.cgi?id=908 if (present) { frame.setUndecorated(true); frame.setBackground(backgroundColor); diff --git a/opengl/src/processing/opengl/PGraphicsOpenGL.java b/opengl/src/processing/opengl/PGraphicsOpenGL.java index 6a3919df5..519423e82 100644 --- a/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -149,6 +149,7 @@ public class PGraphicsOpenGL extends PGraphics3D { // get a rendering surface and a context for this canvas GLDrawableFactory factory = GLDrawableFactory.getFactory(); + /* if (PApplet.platform == PConstants.LINUX) { GraphicsConfiguration pconfig = parent.getGraphicsConfiguration(); System.out.println("parent config is " + pconfig); @@ -162,58 +163,19 @@ public class PGraphicsOpenGL extends PGraphics3D { GraphicsConfiguration config = agc.getGraphicsConfiguration(); System.out.println("agc config is " + config); } + */ drawable = factory.getGLDrawable(parent, capabilities, null); context = drawable.createContext(null); - /* - //System.out.println("creating PGraphicsOpenGL 3"); - canvas.addGLEventListener(new GLEventListener() { - - public void display(GLAutoDrawable drawable) { - // need to get a fresh opengl object here - gl = drawable.getGL(); - parent.handleDraw(); // this means it's time to go - } - - public void init(GLAutoDrawable drawable) { } - - public void displayChanged(GLAutoDrawable drawable, - boolean modeChanged, - boolean deviceChanged) { } - - public void reshape(GLAutoDrawable drawable, - int x, int y, int w, int h) { } - }); - */ - - //System.out.println("creating PGraphicsOpenGL 4"); - - /* - if ((parent != null) && mainDrawingSurface) { - parent.setLayout(null); - parent.add(canvas); - canvas.setBounds(0, 0, width, height); - - //System.out.println("creating PGraphicsOpenGL 5"); - //System.out.println("adding canvas listeners"); - canvas.addMouseListener(parent); - canvas.addMouseMotionListener(parent); - canvas.addKeyListener(parent); - canvas.addFocusListener(parent); - } - */ - // need to get proper opengl context since will be needed below gl = context.getGL(); // Flag defaults to be reset on the next trip into beginDraw(). settingsInited = false; -// System.out.println("allocated."); } else { // changing for 0100, need to resize rather than re-allocate - //canvas.setSize(width, height); - System.out.println("PGraphicsOpenGL.allocate() again for " + width + " " + height); + //System.out.println("PGraphicsOpenGL.allocate() again for " + width + " " + height); reapplySettings(); } }