We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Use multiple Sketch/Application windows
Page Index Toggle Pages: 1
Use multiple Sketch/Application windows (Read 3099 times)
Use multiple Sketch/Application windows
May 19th, 2008, 8:03pm
 
Hello,

I was wondering if its possible to use more than one window for one sketch. For example if you want to run one window fullscreen and a small one with some control/handler things. For example if you'd want to build a small VJ tool and want to run the animation in a seperate window(on another screen) than the controls. I find it pretty hard to put all controls on the keyboard.

greetings!
Re: Use multiple Sketch/Application windows
Reply #1 - May 19th, 2008, 10:06pm
 
Hm, something like that?

Quote:

PFrame f;
secondApplet s;

void setup() {
 size(320, 240);
 PFrame f = new PFrame();
}

void draw() {
  background(255,0,0);
   fill(255);
   rect(10,10,frameCount%100,10);
   s.background(0, 0, 255);
   s.fill(100);
   s.rect(10,20,frameCount%120,10);
   s.redraw();
}

public class PFrame extends Frame {
    public PFrame() {
        setBounds(100,100,400,300);
        s = new secondApplet();
        add(s);
        s.init();
        show();
    }
}

public class secondApplet extends PApplet {
    public void setup() {
        size(400, 300);
        noLoop();
    }

    public void draw() {
    }
}

Re: Use multiple Sketch/Application windows
Reply #2 - May 19th, 2008, 10:08pm
 
this one opens a second OpenGL frame

Quote:

import javax.media.opengl.*;
import com.sun.opengl.util.FPSAnimator;

void setup() {
 size(400, 300);
 
 Frame f = new Frame("OPENGL frame");
 GLCanvas canvas = new GLCanvas();
 canvas.addGLEventListener(new GLRenderer());
 f.add(canvas);
 f.setSize(300, 300);
 f.setLocation(0,0);
 f.setUndecorated(true);
 f.show();
 FPSAnimator animator = new FPSAnimator(canvas, 60);
 animator.start();
}

void draw() {
 background(0);
 fill(255);
 rect(10,10,frameCount%100,10);
}

class GLRenderer implements GLEventListener {
 GL gl;

 public void init(GLAutoDrawable drawable) {
   this.gl = drawable.getGL();
   gl.glClearColor(0, 0, 0, 0);
 }

 public void display(GLAutoDrawable drawable) {
   gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
   gl.glColor3f(1, 1, 1);
   gl.glRectf(-0.8, 0.8, frameCount%100/100f -0.8, 0.7);
 }
 
 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
 }

 public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
 }
}

Re: Use multiple Sketch/Application windows
Reply #3 - May 19th, 2008, 10:10pm
 
I think this is exactly what I needed. I will play around with  this and tell you if I run into any kind of problems. Thanks!
Re: Use multiple Sketch/Application windows
Reply #4 - May 19th, 2008, 10:25pm
 
maybe thats a dumb question but can I run one fullscreen(presentation mode) at a second Monitor while I have the small one on my main Monitor?

I can't test it right now. thanks in advance!
Re: Use multiple Sketch/Application windows
Reply #5 - May 19th, 2008, 10:34pm
 
I think 'presentation mode' doesnt work with two monitors. The second will always be black. Try something with  frame.setUndecorated(true) and frame.setLocation(screen.width,0); If you want to hide Apples menu bar see here -> http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1135921427

greetings ascorbin
Re: Use multiple Sketch/Application windows
Reply #6 - May 19th, 2008, 10:39pm
 
yes thank you, I allready found thos threads. I will see where I can go with this when I have a second monitor!

EDIT:

so even if I use frame.setUndecorated(true); I still have the mac bar of the processing applet on top. But its a good start i guess!

EDIT2:

Okay this code in the setup does it for me:
Quote:

frame.dispose();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice displayDevice=ge.getDefaultScreenDevice();
frame.setUndecorated(true);
displayDevice.setFullScreenWindow(frame);
Dimension fullscreen = frame.getSize();
this.setBounds((fullscreen.width - this.width) / 2,
(fullscreen.height - this.height) / 2,
this.width, this.height);


Re: Use multiple Sketch/Application windows
Reply #7 - May 23rd, 2008, 6:31pm
 
I just realised that Sojamos Controlp5 lib has a nice feature for more windows. So everybody who wants to use a second window to control the main window should take a look at this:

http://www.sojamo.de/libraries/controlP5/

and especially this:

http://www.sojamo.de/libraries/controlP5/examples/ControlP5window/ControlP5window.pde

Thanks for that really great lib!
Re: Use multiple Sketch/Application windows
Reply #8 - Apr 17th, 2010, 1:53am
 
Hi All,

I just started using Processing, so I apologize if this is already clear to others.  I am trying to get two separate opengl windows going and they seem to be conflicting with each other (obviously shared memory buffers, lots of exceptions regarding destroying contexts, etc.)  When I use on with opengl and another with P3D, it works just fine.

Any thoughts?

thanks!
-denny-

Page Index Toggle Pages: 1