<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with #multiplewindows - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23multiplewindows</link>
      <pubDate>Sun, 08 Aug 2021 18:22:11 +0000</pubDate>
         <description>Tagged with #multiplewindows - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23multiplewindows/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>multiple window - clone main window</title>
      <link>https://forum.processing.org/two/discussion/28051/multiple-window-clone-main-window</link>
      <pubDate>Mon, 11 Jun 2018 07:57:22 +0000</pubDate>
      <dc:creator>pietroLama</dc:creator>
      <guid isPermaLink="false">28051@/two/discussions</guid>
      <description><![CDATA[<p>hi to all!</p>

<p>i use processing as my principal instrument to do visual live set, and i've the necessity to clone the main window to another to control what is rendering in that moment!</p>

<p>for now i'm using this code:</p>

<pre><code>class PWindow extends PApplet {
  PWindow() {
    super();
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
  }

  void settings() {
    size(500, 200);
  }

  void setup() {
    background(150);
  }

  void draw() {
    //here i want to clone the main window
  }

  void mousePressed() {
    println("mousePressed in secondary window");
  }
}


PWindow win;

public void settings() {
  size(320, 240);
}

void setup() { 
  win = new PWindow();
}

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

void mousePressed() {
  println("mousePressed in primary window");
}  
</code></pre>

<p>is possible do what i ask starting with this?</p>

<p>thank to everyone!!</p>
]]></description>
   </item>
   <item>
      <title>Can you run a sketch on two screens at the same time?</title>
      <link>https://forum.processing.org/two/discussion/25082/can-you-run-a-sketch-on-two-screens-at-the-same-time</link>
      <pubDate>Sat, 18 Nov 2017 21:14:04 +0000</pubDate>
      <dc:creator>Joar_10_aar</dc:creator>
      <guid isPermaLink="false">25082@/two/discussions</guid>
      <description><![CDATA[<p>Hi!
I want two run my processing sketch at two screens at the same time, is that possible? + I want the sketch to have fullscreen at both screens.</p>
]]></description>
   </item>
   <item>
      <title>Loading images to a second applet?</title>
      <link>https://forum.processing.org/two/discussion/25484/loading-images-to-a-second-applet</link>
      <pubDate>Sun, 10 Dec 2017 01:04:13 +0000</pubDate>
      <dc:creator>LaxOfBayDay</dc:creator>
      <guid isPermaLink="false">25484@/two/discussions</guid>
      <description><![CDATA[<p>I'm creating a program that uses multiple windows.</p>

<p>I finally figured out how to create the second window using the code from <a rel="nofollow" href="https://gist.github.com/atduskgreg/666e46c8408e2a33b09a"><em>here</em>.</a></p>

<p>But when I try to load a picture into it I get a null Pointer exception despite the fact that the image is in the data folder and the named correctly. Any idea why?</p>

<pre><code>//here's the class itself
class PWindow extends PApplet {
   //   PImage[] subs = new PImage[2];
     // String testKey="m";
  PWindow() {
    super();
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);

  }

  void settings() {
    size(1920, 1080);
  }

  void setup() {
    background(150);
      subs[0]=loadImage("test.png");
  }

  void draw() {
    if (keyPressed &amp;&amp; key == testKey.charAt(0)){
    image(subs[0], 0,0);
   println("well it works");
    }
  }

  void mousePressed() {
    println("mousePressed in secondary window");
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Can't load image</title>
      <link>https://forum.processing.org/two/discussion/25448/can-t-load-image</link>
      <pubDate>Fri, 08 Dec 2017 05:37:20 +0000</pubDate>
      <dc:creator>LaxOfBayDay</dc:creator>
      <guid isPermaLink="false">25448@/two/discussions</guid>
      <description><![CDATA[<p>So I need to make an app with two windows. I got this code online and it works but I cant load an image into it (the commented out part is mine). Any idea why the app freezes when I try to run it while loading an image?</p>

<blockquote class="Quote">
  <p>class PWindow extends PApplet {
     //   PImage[] subs = new PImage[2];
       // String testKey="m";
    PWindow() {
      super();
      PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
  <br />
    }</p>
  
  <p>void settings() {
      size(1920, 1080);
    }</p>
  
  <p>void setup() {
      background(150);
      //  subs[0]=loadImage("test.png");
    }</p>
  
  <p>void draw() {
      //if (keyPressed &amp;&amp; key == testKey.charAt(0)){
     // image(subs[0], 0,0);
     println("well it works");
      //}
    }</p>
  
  <p>void mousePressed() {
      println("mousePressed in secondary window");
    }
  }</p>
</blockquote>
]]></description>
   </item>
   <item>
      <title>How to get the number of displays available ?</title>
      <link>https://forum.processing.org/two/discussion/25062/how-to-get-the-number-of-displays-available</link>
      <pubDate>Fri, 17 Nov 2017 11:57:53 +0000</pubDate>
      <dc:creator>schmittmachine</dc:creator>
      <guid isPermaLink="false">25062@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I'd like to have my sketch adapt to the number of screens (display) of the computer.
When more than one screen, I display information on the secondary screens, using the multiple sketches technique (<a rel="nofollow" href="https://forum.processing.org/two/discussion/10937/multiple-sketches">https://forum.processing.org/two/discussion/10937/multiple-sketches</a>, and the new fullScreen(displayNumber) function in these secondary sketches.
But I didn't find any way to computationally know the number of available screens, so as to open the right number of secondary sketches automatically...
I guess that the inner code of fullScreen() knows this number. It would be useful to give access to it in the langage.
Thanks for any hint.</p>
]]></description>
   </item>
   <item>
      <title>second window with PApplet and OscP5?</title>
      <link>https://forum.processing.org/two/discussion/24899/second-window-with-papplet-and-oscp5</link>
      <pubDate>Tue, 07 Nov 2017 16:48:26 +0000</pubDate>
      <dc:creator>jcharney</dc:creator>
      <guid isPermaLink="false">24899@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I'm trying to control a sketch using OSC from Max using the oscP5 library. I want two screens that have identical "players", differentiated by an argument in their constructor. I'm using the "extends PApplet" function to create the second window.</p>

<p>Each Player needs to see global variables that are updated from Max (as sometimes they need to refer to each other's sensor data). I can't seem to figure out where to put the OSC.plug code to make sure each of them gets updated – only the main window updates right now when I put that code within the main setup(), and it doesn't work if I duplicate that code within the second setup(). Do I need to be duplicating the data I'm sending from Max on a separate port, or is there something else I'm not getting? I'm not sure where I should be initializing the Player classes or OSC assignments.</p>

<p>Example of code below (main project has many more functions within the Player class, ie, more roles).</p>

<pre><code>PWindow win;

import oscP5.*;
import netP5.*;

OscP5 osc0;

NetAddress FromMax;    

float sensor0, sensor1; //receive sensor values from Max

int role0, role1; //change modes

Player Player0, Player1;

public void settings(){
  size(800,600);
}

void setup(){
  win = new PWindow();
  Player0 = new Player(0);
  //set up OSC receives
  osc0 = new OscP5(this, 12000);
  FromMax = new NetAddress("127.0.0.1", 12000);
  osc0.plug(this, "oscrole0", "/role0");
  osc0.plug(this, "oscrole1", "/role1");
  osc0.plug(this, "oscsensor0", "/sensor0");
  osc0.plug(this, "oscsensor1", "/sensor1");
}

////First Window
void draw(){
  Player0.update(role0);
}

///Second Window
class PWindow extends PApplet {

  PWindow() {
    super();
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);

  }

  void settings() {
    size(800,600);
  }

  void setup() {
    Player1 = new Player(1);

  }

  void draw() {
  Player1.update(1);
  }
}
/////Player class - one on each screen.
class Player {

  int role;
  int playerNumber;
  float sensor;

  Player (int tempplayerNumber){
    playerNumber = tempplayerNumber;
  }

//  
  void update(int temprole){

  //update sensor
    if (playerNumber == 0){
      role = role0;
      sensor = sensor0; 
       }
    if (playerNumber == 1){
      role = role1;
      sensor = sensor1;
    }

    if (temprole == -1){
      background(0);
      fill(255);
      text(sensor,width/2,height/2);
    }
    if (temprole == 0){
      background(255);
      fill(0);
      text(sensor,width/2,height/2);
    }

    }
}

//reassign OSC plugs
void oscrole0(int oscrole0) {
  role0 = oscrole0;
}

void oscrole1(int oscrole1) {
  role1 = oscrole1;
}

void oscsensor0(float oscsensor0) {
  sensor0 = oscsensor0;
}

void oscsensor1(float oscsensor1) {
  sensor1 = oscsensor1;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>gicentre util multisketch not available</title>
      <link>https://forum.processing.org/two/discussion/17528/gicentre-util-multisketch-not-available</link>
      <pubDate>Thu, 14 Jul 2016 15:07:08 +0000</pubDate>
      <dc:creator>gerome</dc:creator>
      <guid isPermaLink="false">17528@/two/discussions</guid>
      <description><![CDATA[<p>I want to put animations on 2 separate screens. To achieve this I decided to try the gicentre util libraray because it seemes most easy to handle for me. But despite the documentation claims that it is a part of the download package at <a href="http://www.gicentre.net/software/#/utils/" target="_blank" rel="nofollow">http://www.gicentre.net/software/#/utils/</a> it seems that it is not.  I could not found the multiSketch data in the library folder and have no idea where to find it. So import org.gicentre.utils.multisketch.*;  does not function.</p>

<p>Does anybody know where to find that library data?</p>
]]></description>
   </item>
   <item>
      <title>Size problem on two window at the same sketch</title>
      <link>https://forum.processing.org/two/discussion/23268/size-problem-on-two-window-at-the-same-sketch</link>
      <pubDate>Fri, 30 Jun 2017 13:55:56 +0000</pubDate>
      <dc:creator>forty69</dc:creator>
      <guid isPermaLink="false">23268@/two/discussions</guid>
      <description><![CDATA[<p>Hi Everyone,</p>

<p>I have written a code that uses the "controlP5" library. The sketch has some sliders and textboxes. The setup function of the sketch has the information about the position of the gui elements.</p>

<p>So, I want to make a simulation. In fact, I did on other sketch, but I got a size problem when I implement the simulation and the code on the same sketch. Let me explain a bit more about the simulation :</p>

<p>I used P3D to apply the coordinates of the shape by using vertex function.</p>

<p>Here is a quick example of what I did so far :</p>

<pre><code>          public class SecondApplet extends PApplet {
          public void settings() {
                size(1000, 600,P3D);
              }
          public void setup() {

            translate(width/2,height/3, -200);
            stroke(255);
            noFill();

            beginShape();

            vertex(-82.27,0,47.5); vertex(0,0,-23.75);
            vertex(82.27,0,47.5); vertex(-82.27,0,47.5);


            vertex(-270,0,0); vertex(-65,397.5,0);
            vertex(32.5,397.5,-56.3); vertex(32.5,397.5,56.3);

            vertex(-65,397.5,0); vertex(32.5,397.5,56.3);
            vertex(135,0,233.827); vertex(82.27,0,47.5);

            vertex(0,0,-23.75); vertex(135,0,-233.827);
            vertex(32.5,397.5,-56.3);
            endShape();
          }
        }

        void setup() {
          size(1000,800);
          frameRate(25);

          controlP5 = new ControlP5(this);
          controlP5.setAutoInitialization(false);

          /* Setups of the gui elements ...
              -----------------------*/

          SecondApplet sa = new SecondApplet();
          String[] args = {"TwoFrameTest"};
          PApplet.runSketch(args, sa);
          updateGuiElements();
        }
</code></pre>

<p>So, the situation is the size problem on the two windows that I wanted to see when I run the sketch. The main window, which is on the "void setup()" section, is smaller than the second window.</p>

<p>I tried to find out the solution, but I couldn't overcome this problem. What I have to do in order to solve this situation ?</p>

<p>( I tried to explain the problem as well as I can).</p>

<p>I am looking forward to your suggestions. Thanks in advanced.</p>

<p>Have a nice works to all..</p>
]]></description>
   </item>
   <item>
      <title>Run multiple sketchs every couple of minutes randomly</title>
      <link>https://forum.processing.org/two/discussion/23284/run-multiple-sketchs-every-couple-of-minutes-randomly</link>
      <pubDate>Sun, 02 Jul 2017 15:44:49 +0000</pubDate>
      <dc:creator>ayoub</dc:creator>
      <guid isPermaLink="false">23284@/two/discussions</guid>
      <description><![CDATA[<p>Hallo everyone,
I m working on project, where I created 3 sketchs, and I want them to run every couple of minutes randomly. could frameRate() or/and noLoop(), redraw() and loop() work in this case? If yes how do I use them correctly?
Thanks in advance! :)</p>

<p>PS: I m using Kinect for xbox one, the awesome Processing.3 and KinectPV2.</p>
]]></description>
   </item>
   <item>
      <title>Reference instance of another PApplet sketch in Eclipse</title>
      <link>https://forum.processing.org/two/discussion/23178/reference-instance-of-another-papplet-sketch-in-eclipse</link>
      <pubDate>Fri, 23 Jun 2017 11:36:51 +0000</pubDate>
      <dc:creator>brokenAlgorithm</dc:creator>
      <guid isPermaLink="false">23178@/two/discussions</guid>
      <description><![CDATA[<p>I use Eclipse and have a main function which calls 2 different PApplets:</p>

<pre><code>public static void main(String... args){
    PApplet.main("Backend.LaunchBackend");
    PApplet.main("Interface.LaunchInterface");
}
</code></pre>

<p>Inside Backend, I have several classes which reference to LaunchBackend and are constructed via SomeClass(PApplet parent).</p>

<pre><code>Class SomeClass{
    LaunchBackend parent;
    public SomeClass(LaunchBackend parent){
    this.parent = parent;
}
</code></pre>

<p>While coding from within the LaunchBackend PApplet, I can obviously instanciate these via:</p>

<p><code>SomeClass someClass = new SomeClass(this);</code></p>

<p>But what if I want to instanciate the class not from within the LaunchBackend PApplet, but from within the LaunchInterface PApplet? I still want the instance of the object to point to LaunchBackend as its parent, like this:</p>

<p>Within Interface:</p>

<p><code>SomeClass someClass = new SomeClass(***reference to the LaunchBackend PApplet instance***);</code></p>
]]></description>
   </item>
   <item>
      <title>Opening a new P3D window from a 2d main window</title>
      <link>https://forum.processing.org/two/discussion/18419/opening-a-new-p3d-window-from-a-2d-main-window</link>
      <pubDate>Wed, 05 Oct 2016 14:42:21 +0000</pubDate>
      <dc:creator>mala</dc:creator>
      <guid isPermaLink="false">18419@/two/discussions</guid>
      <description><![CDATA[<p>The main part of my sketch is a control window with 4 tabs all consisting of CP5 sliders and buttons, I  also have a separate 3D view window using Proscene which the user interacts with.
Each of these elements I have working on thier own, i.e. if I just have a sketch with the (2D) Control window all works fine, If I have a sketch with just the 3D view interactive view then that works fine.</p>

<p>The problem is combining the two, I can't seem to find the correct way to "start up" the second window which is the P3D window. 
Are there any simple examples anywhere that show this sort of multi window mixed 2d and 3d setup ? 
I have tried to follow the ControlP5Frame example, whilst that kind of works in that it draws my controls, none of the functions connected to those controls continue to work.
Sure I'm missing something very basic here :)</p>
]]></description>
   </item>
   <item>
      <title>Close second window and reopen example.</title>
      <link>https://forum.processing.org/two/discussion/21331/close-second-window-and-reopen-example</link>
      <pubDate>Sat, 11 Mar 2017 11:23:03 +0000</pubDate>
      <dc:creator>jas0501</dc:creator>
      <guid isPermaLink="false">21331@/two/discussions</guid>
      <description><![CDATA[<p>I couldn't find any examples showing 2nd window close without exiting the first. Using <strong><code>exitActual()</code></strong> seems to do the trick. Any comments on this approach versus some alternative?</p>

<p>Note <code>settings()</code> is needed to correctly set the <code>size(500, 500)</code> of the first window. Also  <code>mousePressed()</code> is used to reopen the window.</p>

<pre><code>boolean frame2Exit;
String[] args = {"TwoFrameTest"};
SecondApplet sa;

void settings() {
  size(500, 500);
}
void setup() {
  frame2Start();
}

void draw() {
  background(0);
  ellipse(50, 50, 10, 10);
}     

void mousePressed() {    
  if (frame2Exit)
  {
    frame2Start();
  }
}
void frame2Start() {
  sa = new SecondApplet();
  PApplet.runSketch(args, sa);
  frame2Exit = false;
}

public class SecondApplet extends PApplet {

  public void settings() {
    size(300, 300);
   }
  public void draw() {
    background(255);
    fill(0);
    ellipse(100, 50, 10, 10);
  }
  public void exitActual() {
    frame2Exit = true; 
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I Create a separate Image in the "Main" Window</title>
      <link>https://forum.processing.org/two/discussion/20867/how-can-i-create-a-separate-image-in-the-main-window</link>
      <pubDate>Sat, 18 Feb 2017 15:42:36 +0000</pubDate>
      <dc:creator>Reefhermit</dc:creator>
      <guid isPermaLink="false">20867@/two/discussions</guid>
      <description><![CDATA[<p>I am reading sensor data through I2C on the Raspberry Pi, number crunching and displaying (realtime) in the window . . . size(420,420). No problem, all working as required! Now, I would like to have a 2nd window for a GUI. I have tried using CreateImage (which seems to put a window in the main window) to no avail. The one thing I notice is that the program code always seems to prefer displaying in the "main" window and ignores all attempts to create this 2nd window?! I suspect the realtime activity is a problem.</p>

<p>Would switching to a more current coding system like processing.js, p5.js or processing.py help?</p>

<p>Any advice would be appreciated.</p>
]]></description>
   </item>
   <item>
      <title>How can I control my particles in one window from another window via the mouse?</title>
      <link>https://forum.processing.org/two/discussion/19895/how-can-i-control-my-particles-in-one-window-from-another-window-via-the-mouse</link>
      <pubDate>Sat, 24 Dec 2016 02:10:25 +0000</pubDate>
      <dc:creator>slow_izzm</dc:creator>
      <guid isPermaLink="false">19895@/two/discussions</guid>
      <description><![CDATA[<p>I am not sure if I am missing something specific to the toxi library, but I keep getting a <strong>ConcurrentModificationException</strong> when I try to control my particles in my secondary window via the mouse in my primary window. The crash seems to be random, sometimes it crashes on one click, sometimes I can drag the particles around for a second or two either way I can;t seem to figure it out. Can anyone help, please?</p>

<pre><code>Particles p;
AttractionBehavior mouseAttractorP;
Vec2D mousePos;
FinalPanel tp;

void setup() {
  size(1024, 768, P3D);
  frameRate(60);
  tp = new FinalPanel(400,400);
  surface.setTitle("Touch Panel");

}

void draw() {
  background(0, 0, 0);
}



void mousePressed() {
  mousePos = new Vec2D(mouseX, mouseY);

  if (mouseButton == LEFT) {
    // create a new attraction force field around the mouse position
    mouseAttractorP = new AttractionBehavior(mousePos, 250, 7);
    p.physics.addBehavior(mouseAttractorP);
  }

  if (mouseButton == RIGHT) {
    // create a new repulsion force field around the mouse position
    mouseAttractorP = new AttractionBehavior(mousePos, -33, -1);
    p.physics.addBehavior(mouseAttractorP);
  }
}

void mouseDragged() {
  // update mouse attraction focal point
  mousePos.set(mouseX, mouseY);
}

void mouseReleased() {
  // remove the mouse attraction when button has been released
  p.physics.removeBehavior(mouseAttractorP);
}


import toxi.geom.*;
import toxi.physics2d.*;
import toxi.physics2d.behaviors.*;
import toxi.math.*;
import megamu.mesh.*;



class Particles {
  final PApplet g;
  int NUM_PARTICLES;
  VerletPhysics2D physics;
  AttractionBehavior mouseAttractor;
  float [][] pos;
  float eSize;
  float xOff;

  Delaunay delaunay;
  int [] polygons;


  Particles(PApplet _p) {
    g = _p;
    xOff = 0;


    NUM_PARTICLES = 666;
    eSize = 1;
    physics = new VerletPhysics2D();
    physics.setDrag(0.7);
    physics.setWorldBounds(new Rect(0, 0, width, height));
    physics.addBehavior(new GravityBehavior(new Vec2D(-0.00007, -0.0003f)));
    for (int i = 0; i&lt;NUM_PARTICLES; i++) {
      addParticle();
    }
  }


  void addParticle() {
    VerletParticle2D p = new VerletParticle2D(Vec2D.randomVector().scale(133).addSelf(width / 2, height/2));
    physics.addParticle(p);
    // add a negative attraction force field around the new particle
    physics.addBehavior(new AttractionBehavior(p, 13, 0.3f, 3f));
  }

  void drawParticles() {
    // store particles delaunayitions to do delaunay triangulation
    pos = new float[NUM_PARTICLES][2];

    for ( int i=0; i&lt;NUM_PARTICLES; i++) {
      // particle system using verlet integration
      VerletParticle2D p = physics.particles.get(i);
      g.pushStyle();
      g.fill(255, 33);
      g.ellipse(p.x, p.y, g.noise(xOff) * 13, g.noise(xOff) * 13);
      g.popStyle();

      pos[i][0] = physics.particles.get(i).x;
      pos[i][1] = physics.particles.get(i).y;
    }
  }


  // delaunay triangulation logic taken from here : 
  // <a href="http://www.openprocessing.org/sketch/43503" target="_blank" rel="nofollow">http://www.openprocessing.org/sketch/43503</a>
  void drawLines() {
    // delaunay triangulation
    delaunay = new Delaunay(pos);
    // getEdges returns a 2 dimensional array for the lines
    float[][] edges = delaunay.getEdges();
    for (int i=0; i&lt;edges.length; i++)
    {
      // use the edges values to draw the lines
      float startX = edges[i][0];
      float startY = edges[i][1];
      float endX = edges[i][2];
      float endY = edges[i][3];
      float distance = dist(startX, startY, endX, endY);
      // remap the distance to opacity values
      float trans = 255-map(distance, 0, 33, 33, 0);
      // stroke weight based on distance
      // fast invert square root helps for performance
      float sw = 3f/sqrt(distance*2);
      g.ellipseMode(CENTER);

      g.pushStyle();
      g.strokeWeight(sw);
      g.stroke(g.noise(1)*233);
      g.fill(g.random(255), g.random(255), g.random(255));
      g.noFill();
      g.ellipse(startX, startY, eSize, eSize);
      g.popStyle();
      //pushStyle();
      //stroke(200, 3);
      //noFill();
      //bezier(startX, startY, endX, mouseY, width/2, mouseY, width/2, height/2);
      //popStyle();
    }
  }
}



class FinalPanel extends PApplet {
  int w, h;

  public FinalPanel(int _w, int _h) {
    super(); 
    w = _w;
    h = _h;
    PApplet.runSketch(new String[]{this.getClass().getName()}, this);
  }

  public void settings() {
    size(w, h, P3D);
  }

  public void setup() {
    blendMode(ADD);
    surface.setTitle("Final Panel");
    surface.setLocation(0, 0);
    p = new Particles(this);
  }

  void draw() {
    background(0);
    p.physics.update();
    p.drawParticles();
    p.drawLines();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>too many calls to popMatrix and issues generating text (Eclipse IDE)</title>
      <link>https://forum.processing.org/two/discussion/19701/too-many-calls-to-popmatrix-and-issues-generating-text-eclipse-ide</link>
      <pubDate>Mon, 12 Dec 2016 16:38:11 +0000</pubDate>
      <dc:creator>JDev</dc:creator>
      <guid isPermaLink="false">19701@/two/discussions</guid>
      <description><![CDATA[<p>I'm developing a Processing view (with v2.2.1 that still extends Applet). I use some pushMatrix()/popMatrix() to do transformations and to represent composite objects (I'm aware of the 32 depth matrix stack limit and relatively sure I don't reach that depth in composition and/or successive transformations or dont pair push and pops properly).</p>

<p>So far I didn't have any unexpected issue, but after introducing yet another component(not the first text enabled component at all), I'm starting to occasionally get errors like these:</p>

<p>The font size is too large to be properly displayed with OpenGL</p>

<p>Exception in thread "Animation Thread" java.lang.RuntimeException: Image width and height cannot be larger than 0 with this graphics card. at processing.opengl.Texture.setSize(Texture.java:1148) at processing.opengl.Texture.init(Texture.java:213) at processing.opengl.Texture.(Texture.java:160) at processing.opengl.FontTexture.addTexture(FontTexture.java:134) at processing.opengl.FontTexture.initTexture(FontTexture.java:103) at processing.opengl.FontTexture.(FontTexture.java:71) at processing.opengl.PGraphicsOpenGL.textLineImpl(PGraphicsOpenGL.java:3602) at processing.core.PGraphics.textLineAlignImpl(PGraphics.java:4659) at processing.core.PGraphics.text(PGraphics.java:4356) at processing.core.PGraphics.text(PGraphics.java:4307) at processing.core.PApplet.text(PApplet.java:13183) at ygg.desktop.vm.extVM.MetadataProcessingVM.render(MetadataProcessingVM.java:81) at ygg.desktop.vm.extVM.MetadataProcessingVM.render(MetadataProcessingVM.java:88) at ygg.desktop.vm.groups.TreeLayout.render(TreeLayout.java:43) at ygg.desktop.vm.groups.RenderArea.render(RenderArea.java:167) at ygg.desktop.view.MainView.draw(MainView.java:179) at processing.core.PApplet.handleDraw(PApplet.java:2386) at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240) at processing.core.PApplet.run(PApplet.java:2256) at java.lang.Thread.run(Thread.java:745)
which refers to (note that I get it both on first and second text on different runs) *father is the PApplet instance</p>

<pre><code>      father.pushMatrix();
      father.translate(posX, posY+8);

      father.rotate(-father.HALF_PI);

      father.fill(father.color(30,30,30));
      father.textAlign(father.CENTER);
      father.textSize(16);
      **father.text(md.getId()!=null?md.getId():"NONE",-(finalY-posY)/2,width/2);**
      father.fill(father.color(220,220,50));
      father.textSize(12);
      **father.text(md.getId()!=null?md.getId():"NONE",-(finalY-posY)/2,width/2);**

      father.popMatrix();
</code></pre>

<p>or</p>

<p>Exception in thread "Animation Thread" java.lang.RuntimeException: Too many calls to popMatrix(), and not enough to pushMatrix(). at processing.opengl.PGraphicsOpenGL.popMatrix(PGraphicsOpenGL.java:3811) at processing.core.PApplet.popMatrix(PApplet.java:13322) at ygg.desktop.vm.extVM.MetadataProcessingVM.render(MetadataProcessingVM.java:72) at ygg.desktop.vm.groups.TreeLayout.render(TreeLayout.java:43) at ygg.desktop.vm.groups.TreeLayout.render(TreeLayout.java:46) at ygg.desktop.vm.groups.TreeLayout.render(TreeLayout.java:46) at ygg.desktop.vm.groups.RenderArea.render(RenderArea.java:167) at ygg.desktop.view.MainView.draw(MainView.java:180) at processing.core.PApplet.handleDraw(PApplet.java:2386) at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240) at processing.core.PApplet.run(PApplet.java:2256) at java.lang.Thread.run(Thread.java:745)
on</p>

<pre><code>      father.pushMatrix();
      father.translate(posX, posY+8);
      father.rotate(-father.HALF_PI);
      father.fill(father.color(30,30,30));
      father.textAlign(father.CENTER);
      father.textSize(16);

      father.text(md.getId()!=null?md.getId():"NONE",-(finalY-posY)/2,width/2);
      father.fill(father.color(220,220,50));
      father.textSize(12);
      father.text(md.getId()!=null?md.getId():"NONE",-(finalY-posY)/2,width/2);      
      **father.popMatrix();**
}
</code></pre>

<p>I am no expert in OpenGl and/or Processing at all, so I was wondering how can successive executions (with no previous jvm left open) lead to different outcomes without any random element in my code (apparently if the application doesnt crash immediately it keeps working no matter how many objects I create), also I don't understand how can I get that exception on popMatrix right after a push given that all the calls are in the draw cycle and of course no thread (that I'm aware) there.</p>

<p>Before proceeding I would like to know what am I getting so wrong (if it as already transpired) and what could I do to achieve stability at each run, also I would like to know if multiple instances of PApplet clients will necessarly confict with each others.</p>
]]></description>
   </item>
   <item>
      <title>Create a new window/PApplet from another PApplet</title>
      <link>https://forum.processing.org/two/discussion/19677/create-a-new-window-papplet-from-another-papplet</link>
      <pubDate>Mon, 12 Dec 2016 01:02:56 +0000</pubDate>
      <dc:creator>colouredmirrorball</dc:creator>
      <guid isPermaLink="false">19677@/two/discussions</guid>
      <description><![CDATA[<p>I stumbled upon a way to easily spawn new windows from Processing and couldn't find it anywhere else so I thought I'd post it here. Unsure if it's the best way but it appears to be working. Feedback and improvements appreciated. This will only work for Processing 3.</p>

<p>First tab, for the demo to work right out of the box this sketch <strong>has</strong> to be called "SecondWindowTest"</p>

<pre><code>/**
 * Demo on how to spawn a second sketch from Processing
 * Facilitated by ControlP5, but not necessary for this purpose
 * by CMB, 2016
 *
 */



import controlP5.*;

ControlP5 cp5;

//Reference to the secondary sketch so we can call its methods and access its variables from outside
SecondSketch second;

//This value will be accessed by the other sketch
int backgroundValue = 0;

public void settings()
{
  size(800, 600);
}

public void setup()
{
  surface.setResizable(true);

  cp5 = new ControlP5(this);

  cp5.addButton("secondWindow")
    .setPosition(20, 20)
    .setSize(125, 25)
    .setLabel("Second Window")
    .getCaptionLabel().alignY(CENTER).alignX(CENTER);

  cp5.addTextfield("textField")
    .setSize(125, 25)
    .setPosition(20, 75);
}

public void draw()
{
  background(backgroundValue);
}

public void secondWindow()
{
  //Launch the other sketch!

  //This structure assumes you only want one instance of the other sketch
  //If that's not what you want simply call the constructor to launch a new, independent instance

  //if the other sketch is closed, start a new one
  if (second== null) second = new SecondSketch(this);
  else
  {
    //if it's already running, bring it to the front
    second.moveToTop();
  }
}

public void textField(String input)
{
  //Send some text to the other sketch
  if (second != null)
  {
    second.someText = input;
  }
}
</code></pre>

<p>Second tab</p>

<pre><code>//Code in this class like in any other sketch
//However, this class can't have any nested classes like a regular sketch:
//if you want to use another class inside this secondary sketch and draw in it,
//you gotta pass it a reference to this class and draw on its internal PGraphics "g"
class SecondSketch extends PApplet
{
  //A reference to the main sketch
  //notice how the file name of the main sketch is important as that becomes the name of the class upon compiling
  SecondWindowTest parent;

  ControlP5 gui;

  //This String will be sent to us from the main sketch
  String someText= "";

  //The constructor will take care of everything
  public SecondSketch(SecondWindowTest parent)
  {
    //store a reference to the first sketch so we can do things with it
    this.parent = parent;

    //This will actually launch the new sketch
    runSketch(new String[] {
      "SecondSketch"  //must match the name of this class
      }
      , this);  //the second argument makes sure this sketch is created instead of a brand new one...
  }

  public void settings()
  {
    size(700, 500);
  }

  public void setup()
  {

    super.surface.setResizable(true);

    //give it some GUI to interact with
    gui = new ControlP5(this);
    gui.addSlider("mainBackground")
      .setRange(0, 255)
      .setPosition(20, 50)
      .setLabel("Main sketch background colour")
      .setSize(125, 25);
  }

  public void draw()
  {
    background(50);
    fill(255);

    //Display the text that can be altered from the main sketch
    text(someText, 20, 20);
  }

  //Without this, the main sketch would close if the user clicked on the second sketch' close button!
  //(it appears to work funky with the escape button though, beware)
  public void exit()
  {
    parent.second = null;
    dispose();
  }

  //Callback from ControlP5
  public void mainBackground(float value)
  {
    //Change main sketch' background value
    parent.backgroundValue = (int) value;
  }

  //Little hack to bring the frame to the top
  public void moveToTop()
  {
    surface.setAlwaysOnTop(true);
    surface.setAlwaysOnTop(false);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>ControlP5 : Pressing a button shows another frame.</title>
      <link>https://forum.processing.org/two/discussion/19610/controlp5-pressing-a-button-shows-another-frame</link>
      <pubDate>Thu, 08 Dec 2016 14:53:31 +0000</pubDate>
      <dc:creator>xkapono22</dc:creator>
      <guid isPermaLink="false">19610@/two/discussions</guid>
      <description><![CDATA[<p>Any idea how does it work? I know the concept of creating a button by this library. What I do not know is the syntax to create a new frame that has another program. Let's say if I press a button, this button will actually display a new frame that has a program in it. I hope you all understand. Thanks and have a good day.</p>
]]></description>
   </item>
   <item>
      <title>Two differents projectors for the same Scene with Processing 3</title>
      <link>https://forum.processing.org/two/discussion/18825/two-differents-projectors-for-the-same-scene-with-processing-3</link>
      <pubDate>Tue, 01 Nov 2016 15:43:21 +0000</pubDate>
      <dc:creator>agrignard</dc:creator>
      <guid isPermaLink="false">18825@/two/discussions</guid>
      <description><![CDATA[<p>I'd like to display my scene on two different projector. I want to split my scene in two by drawing the left side on the left projector and the right part on the right projector to get a bigger display surface.</p>

<p>On processing 2 this solution is working:
<a href="http://stackoverflow.com/questions/20737298/multiple-render-to-two-projectors-using-processing-for-polarization-based-3d/40363398#40363398" target="_blank" rel="nofollow">http://stackoverflow.com/questions/20737298/multiple-render-to-two-projectors-using-processing-for-polarization-based-3d/40363398#40363398</a></p>

<p>But it does not compile on Processing 3. Does anyone has any idea?</p>
]]></description>
   </item>
   <item>
      <title>2 separate screens in Processing 3</title>
      <link>https://forum.processing.org/two/discussion/17529/2-separate-screens-in-processing-3</link>
      <pubDate>Thu, 14 Jul 2016 16:08:12 +0000</pubDate>
      <dc:creator>gerome</dc:creator>
      <guid isPermaLink="false">17529@/two/discussions</guid>
      <description><![CDATA[<p>I want to put animations on 2 separate screens, one in Java2D, one in P3D. The available examples for that seem to function for P2 e.g. Multiple Nested PApplets (v2.0)  by GoToLoop in the discussion <a href="https://forum.processing.org/two/discussion/10937/multiple-sketches" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/10937/multiple-sketches</a></p>

<p>I do not know enough about Java and Processing to adapt this code to P3. Could someone link me to a functioning P3 example.</p>

<p>Help is much appreciated.</p>
]]></description>
   </item>
   <item>
      <title>ConcurrentModificationException</title>
      <link>https://forum.processing.org/two/discussion/18353/concurrentmodificationexception</link>
      <pubDate>Fri, 30 Sep 2016 06:27:02 +0000</pubDate>
      <dc:creator>mcdpdr</dc:creator>
      <guid isPermaLink="false">18353@/two/discussions</guid>
      <description><![CDATA[<pre><code>Hi I only started months ago using Processing. I used the library ControlP5 to create my GUI. I modified the example provided by the library called ControlP5Frames in /controllers. I want to display another window when I pressed a button in the main window. My problem is, error _ConcurrentModificationException_ occurs when I close the second window. 


Below is my code:

`import java.awt.*;
import java.awt.event.*;
import controlP5.*;

private ControlP5 cp5;

ControlFrame cfConfig;

String actualColors[] = {"Red","Green","Blue","Yellow"};
  String arrangement[] = {"Corners","All Top","Right Side","Left Side"};
  int selectedColors[] = new int[4];
  int selectedArrangement = 0;
  int removeMe;

void initMainGUI(){

  cp5.addButton("config")
     .setLabel("Configuration")
     .setPosition(100,400)
     .setSize(200,19)
     ;

  cp5.addButton("homePosition")
     .setLabel("Home Position")
     .setPosition(400,400)
     .setSize(200,19)
     ;

  cp5.addButton("systemStart")
     .setLabel("Start Sorting")
     .setPosition(700,400)
     .setSize(200,19)
     ;

}

void config(){
 cfConfig = addControlFrame( "Configuration", 720, 600, 20, 50, color( 100 ), 0);
}

void setup(){
  size(1000, 500);
  cp5 = new ControlP5(this);

  initMainGUI();
}

void draw(){

}

ControlFrame addControlFrame(String theName, int theWidth, int theHeight, int theX, int theY, int theColor ,int type) {
  final Frame f = new Frame( theName );
  final ControlFrame p = new ControlFrame( this, theWidth, theHeight, theColor, type);

  f.add( p );
  p.init();
  f.setTitle(theName);
  f.setSize( p.w, p.h );
  f.setLocation( theX, theY );
  f.addWindowListener( new WindowAdapter() {
      public void windowClosing(WindowEvent we) {
      p.dispose();
      f.dispose();
    }
  } 
  );
  f.setResizable( false );
  f.setVisible( true );
  // sleep a little bit to allow p to call setup.
  // otherwise a nullpointerexception might be caused.
  try {
    Thread.sleep( 100 );
  } 
  catch(Exception e) {
  }
  return p;
}

class ControlFrame extends PApplet {

  int w, h;
  int bg;
  int windowType;
  PApplet parent;
  ControlP5 cp5;

  public ControlFrame(PApplet _parent, int _w, int _h, int theColor,int type) {
    super();   
    parent = _parent;
    w=_w;
    h=_h;
    bg = theColor;
    windowType=type;
  }


  public void setup() {
    size(w, h);
    cp5 = new ControlP5(this);
    if(windowType==0){
      initConfig();   
    }
  }

  public void initConfig(){

  cp5.addScrollableList("prioOne")
     .setLabel(" ")
     .setPosition(100, 60)
     .setSize(100, 100)
     .setBarHeight(20)
     .setItemHeight(20)
     .addItems(actualColors)
     .setOpen(false)
     ;

  cp5.addTextlabel("labelOnce")
    .setText("Priority One")
    .setFont(createFont("Calibri",12))
    .setPosition(20,60)
    .setColorValue(#000000)
    ; 

   cp5.addTextlabel("labelTwo")
    .setText("Priority Two")
    .setFont(createFont("Calibri",12))
    .setPosition(20,90)
    .setColorValue(#000000)
    ; 

   cp5.addTextlabel("labelThree")
    .setText("Priority Three")
    .setFont(createFont("Calibri",12))
    .setPosition(20,120)
    .setColorValue(#000000)
    ; 

   cp5.addTextlabel("labelFour")
    .setText("Priority Four")
    .setFont(createFont("Calibri",12))
    .setPosition(20,150)
    .setColorValue(#000000)
    ; 

   cp5.addTextlabel("labelFive")
    .setText("Arrangement")
    .setFont(createFont("Calibri",12))
    .setPosition(20,180)
    .setColorValue(#000000)
    ; 

  cp5.addTextlabel("labePOH")
  .setText("Priority One H")
  .setFont(createFont("Calibri",12))
  .setPosition(20,250)
  .setColorValue(#000000)
  ;  

  cp5.addTextlabel("labePTH")
  .setText("Priority Two H")
  .setFont(createFont("Calibri",12))
  .setPosition(20,310)
  .setColorValue(#000000)
  ; 

  cp5.addTextlabel("labePThH")
  .setText("Priority Three H")
  .setFont(createFont("Calibri",12))
  .setPosition(20,370)
  .setColorValue(#000000)
  ; 

  cp5.addTextlabel("labePFH")
  .setText("Priority Four H")
  .setFont(createFont("Calibri",12))
  .setPosition(20,430)
  .setColorValue(#000000)
  ; 

  cp5.addTextlabel("labeSmtH")
  .setText("Gripper H")
  .setFont(createFont("Calibri",12))
  .setPosition(20,490)
  .setColorValue(#000000)
  ; 

  }

  boolean updateGui=false;
  int nextState=0;

  void updatingGui(){
  if(nextState==1){
    cp5.addScrollableList("prioTwo")
   .setLabel(" ")
   .setPosition(100, 90)
   .setSize(100, 100)
   .setBarHeight(20)
   .setItemHeight(20)
   .addItems(actualColors)
   .setOpen(false)
   .bringToFront();
   ;
  }else if(nextState==2){
    cp5.addScrollableList("prioThree")
   .setLabel(" ")
   .setPosition(100, 120)
   .setSize(100, 100)
   .setBarHeight(20)
   .setItemHeight(20)
   .addItems(actualColors)
   .setOpen(false)
   .bringToFront();
   ;
  }else if(nextState==3){
    cp5.addScrollableList("prioFour")
   .setLabel(" ")
   .setPosition(100, 150)
   .setSize(100, 100)
   .setBarHeight(20)
   .setItemHeight(20)
   .addItems(actualColors)
   .setOpen(false)
   .bringToFront();
   ;
  }else if(nextState==4){
    cp5.addScrollableList("prioFive")
   .setLabel(" ")
   .setPosition(100, 180)
   .setSize(100, 100)
   .setBarHeight(20)
   .setItemHeight(20)
   .addItems(arrangement)
   .setOpen(false)
   .bringToFront();
   ;
  }else if(nextState==5){
   cp5.addSlider("oneH")
     .setPosition(20,270)
     .setSize(200,20)
     .setRange(0,255)
     .setValue(128)
     .getCaptionLabel().align(ControlP5.TOP, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
     ;

   cp5.addSlider("twoH")
   .setPosition(20,330)
   .setSize(200,20)
   .setRange(0,255)
   .setValue(128)
   .getCaptionLabel().align(ControlP5.TOP, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
   ;

   cp5.addSlider("threeH")
     .setPosition(20,390)
     .setSize(200,20)
     .setRange(0,255)
     .setValue(128)
     .getCaptionLabel().align(ControlP5.TOP, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
     ;

   cp5.addSlider("fourH")
     .setPosition(20,450)
     .setSize(200,20)
     .setRange(0,255)
     .setValue(128)
     .getCaptionLabel().align(ControlP5.TOP, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
     ;

   cp5.addSlider("fiveH")
     .setPosition(20,510)
     .setSize(200,20)
     .setRange(0,255)
     .setValue(128)
     .getCaptionLabel().align(ControlP5.TOP, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
     ;

    }
  updateGui=false;
  }

  boolean prioOne=true;

  void prioOne(int n){
    println("Priority One: " + actualColors[n]);
    selectedColors[0]=n;
    if(prioOne){
      updateGui=true;
      nextState=1;
      prioOne=false;
    }
  }

  boolean prioTwo=true;

  void prioTwo(int n){
    println("Priority Two: " + actualColors[n]);
    selectedColors[1]=n;
    removeMe=n;
    if(prioTwo){
      updateGui=true;
      nextState=2;
      prioTwo=false;
    }
  }

  boolean prioThree=true;

  void prioThree(int n){
    println("Priority Three: " + actualColors[n]);
    selectedColors[2]=n;
    removeMe=n;
    if(prioThree){
      updateGui=true;
      nextState=3;
      prioThree=false;
    }
  }

  boolean prioFour=true;

  void prioFour(int n){
    println("Priority Four: " + actualColors[n]);
    selectedColors[3]=n;
    removeMe=n;
    if(prioFour){
      updateGui=true;
      nextState=4;
      prioFour=false;
    }
  }

  boolean prioFive=true;

  void prioFive(int n){
    println("Arrangement: "+arrangement[n]);
    selectedArrangement=n;
    removeMe=n;
    if(prioFive){
      updateGui=true;
      nextState=5;
      prioFive=false;
    }

  }

  void oneH(int theColor) {
    println("Priority One H: "+theColor);
  }

  void twoH(int theColor) {
    println("Priority Two H: "+theColor);
  }

  void threeH(int theColor) {
    println("Priority Three H: "+theColor);
  }

  void fourH(int theColor) {
    println("Priority Four H: "+theColor);
  }

  void fiveH(int theColor) {
    println("Gripper H: "+theColor);
  }

  public void draw(){
    background(bg);
    if(updateGui){
     updatingGui(); 
    }
  }


}


`
</code></pre>
]]></description>
   </item>
   <item>
      <title>Multiple screens</title>
      <link>https://forum.processing.org/two/discussion/7036/multiple-screens</link>
      <pubDate>Fri, 05 Sep 2014 07:40:15 +0000</pubDate>
      <dc:creator>alejandro</dc:creator>
      <guid isPermaLink="false">7036@/two/discussions</guid>
      <description><![CDATA[<p>I have a screen that contains the values ​​that are changed continuously by the users, these values ​​(not all) should be seen on a second screen. does anyone know how to do? sorry but I'm new with processing ..</p>
]]></description>
   </item>
   <item>
      <title>open a new sketch on a button click?</title>
      <link>https://forum.processing.org/two/discussion/16358/open-a-new-sketch-on-a-button-click</link>
      <pubDate>Sat, 30 Apr 2016 08:29:36 +0000</pubDate>
      <dc:creator>fadingbeat</dc:creator>
      <guid isPermaLink="false">16358@/two/discussions</guid>
      <description><![CDATA[<p>hello hello. I'm building a small program for my thesis. It includes several buttons and i want those buttons, when clicked, to open a new sketch. Is that possible or is it done in some other way?</p>

<p>I'm familiar with Java but if it's done differently in Processing, i would like to know. Also i failed in search of this on forums and google, so i'm hoping for some direction if the question or topic already exists. Thank you</p>

<p>All the examples i found include only visual changes when button clicked, for example:</p>

<p>if(button.clicked)background(#somecolor);</p>

<p>I was hoping it would be that simple with invoking another sketch. 
thank you</p>
]]></description>
   </item>
   <item>
      <title>Multiple windows navigation</title>
      <link>https://forum.processing.org/two/discussion/17625/multiple-windows-navigation</link>
      <pubDate>Sat, 23 Jul 2016 08:22:36 +0000</pubDate>
      <dc:creator>OmarDahmen</dc:creator>
      <guid isPermaLink="false">17625@/two/discussions</guid>
      <description><![CDATA[<p>I'm working on a professional project, I'm trying to use Processing with java mode, but I'm finding some issues.
My question is :
How to create multiple windows and pass from one window to another, somehow only one window will be shown?</p>
]]></description>
   </item>
   <item>
      <title>3D renderer not recognized in secondApplet</title>
      <link>https://forum.processing.org/two/discussion/17585/3d-renderer-not-recognized-in-secondapplet</link>
      <pubDate>Tue, 19 Jul 2016 14:18:46 +0000</pubDate>
      <dc:creator>gerome</dc:creator>
      <guid isPermaLink="false">17585@/two/discussions</guid>
      <description><![CDATA[<p>the P3D renderer in the following sketch with 2 windows in PS3 is not recognized. I get the error:</p>

<p>vertex() with x, y, and z coordinates can only be used with a renderer that supports 3D, such as P3D... .</p>

<p>if I put the content of the class Tetra inside a function and call it in draw() the problem does not appear?</p>

<p>a hint to solve this would be great. :)</p>

<pre><code>float ballX;
float ballY;

float theta = 0.0;

Tetra tetra;

public void setup() {
  size(900, 900, JAVA2D);

  String[] args = {"SecondApplet"};
  SecondApplet sa = new SecondApplet();
  PApplet.runSketch(args, sa);
}

void draw() {
  ballX = mouseX;
  ballY = mouseY;
  background(0);
  ellipse(ballX, ballY, 10, 10);
}   

public class SecondApplet extends PApplet {

  public void settings() {
    size(900, 900, P3D);
    tetra = new Tetra(10); 
  }

 public void setup() {
    frameRate(30);   
  } 

  public void draw() {
   background(255);
  theta += 0.01;

  translate(width/2, height/2, 0);
  rotateX(theta);
  rotateY(theta);  

  // translate the scene again
  translate(100, 100, 20);
  shape(tetra.gr); 
  }
}

public class Tetra {

  // The PShape object
 PShape gr;
  int t;

  Tetra(int t_) {
    t = t_;

    gr = createShape();

    beginShape();
    fill(150, 0, 0, 127);
    vertex(-t, -t, -t);
    vertex( t, -t, -t);
    vertex( 0, 0, t);

    fill(0, 150, 0, 127);
    vertex( t, -t, -t);
    vertex( t, t, -t);
    vertex( 0, 0, t);

    fill(0, 0, 150, 127);
    vertex( t, t, -t);
    vertex(-t, t, -t);
    vertex( 0, 0, t);

    fill(150, 0, 150, 127);
    vertex(-t, t, -t);
    vertex(-t, -t, -t);
    vertex( 0, 0, t);

    endShape();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Multiple sketches</title>
      <link>https://forum.processing.org/two/discussion/10937/multiple-sketches</link>
      <pubDate>Thu, 21 May 2015 14:35:09 +0000</pubDate>
      <dc:creator>druid</dc:creator>
      <guid isPermaLink="false">10937@/two/discussions</guid>
      <description><![CDATA[<p>Howdy, i'm doing a work and I want to, by a menu with several options, click an option and a diferent sketch appears in a pop up window, i have already all the sketches done I just need to "glue" them together and i dont know how, I've tried multisketch but i don't think it lets me use more than two sketches. please help!! thanks 8)</p>
]]></description>
   </item>
   <item>
      <title>How to open a second window?</title>
      <link>https://forum.processing.org/two/discussion/16965/how-to-open-a-second-window</link>
      <pubDate>Fri, 03 Jun 2016 03:24:59 +0000</pubDate>
      <dc:creator>wsl1998</dc:creator>
      <guid isPermaLink="false">16965@/two/discussions</guid>
      <description><![CDATA[<p>I'm working on a project and I need to create a second window. Does anyone know how this can be done?</p>
]]></description>
   </item>
   <item>
      <title>PShape and runSketch NullPoinerException issue</title>
      <link>https://forum.processing.org/two/discussion/16669/pshape-and-runsketch-nullpoinerexception-issue</link>
      <pubDate>Wed, 18 May 2016 04:49:13 +0000</pubDate>
      <dc:creator>bontempos</dc:creator>
      <guid isPermaLink="false">16669@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to open a second window using runSketch on processing 3...</p>

<p>it works, <strong>until</strong> I try to import a PShape obj file.</p>

<p>obj file in this <a rel="nofollow" href="https://drive.google.com/file/d/0B7SwFIjr6ECad29OMTRRdE9Qa0k/view?ts=573bf2ea">folder</a>:</p>

<p>PShape obj file can be imported, IF, i give up the second window ... :| it is frustrating...</p>

<p>Is there any other way I can build a fullScreen window as a second window without extending PApplet, just using frame or surface?</p>

<pre><code>PShape s;

void setup() {
  size(100, 100,P3D);

  String[] args = {"YourSketchNameHere"};
  SecondApplet sa = new SecondApplet();
  PApplet.runSketch(args, sa);

  s = loadShape("box1.obj"); // in order to open 2 windows, i need to comment this and //shape(s,0,0);
}

void draw() {
  background(0);
  ellipse(50, 50, 10, 10);
  text("MAIN",40,40);
  shape(s, 0, 0); 
}     

//if I remove code below and comment its calling lines at setup() obj file will be imported.
public class SecondApplet extends PApplet {

  public void settings() {
    fullScreen(P3D, 2);
  }
  public void draw() {
    background(255);
    fill(0);
    ellipse(100, 50, 10, 10);
  }
}
</code></pre>

<p>this next code is just a variation, but still same problem.</p>

<pre><code>PShape s;

void setup() {
  size(200, 200, P3D);
  s = loadShape("box.obj");
  SecondApplet cp = new SecondApplet("controlWindow");

}

void draw() {
  background(0);
  ellipse(50, 50, 10, 10);
  text("MAIN", 40, 40);
  shape(s, 0, 0);
}     

public class SecondApplet extends PApplet {

  SecondApplet(String _name) {
    super();   
    PApplet.runSketch(new String[]{this.getClass().getName()}, this);
  }
  void settings() {
    fullScreen(P3D, 2);
  }
  void draw() {
    background(255);
    fill(0);
    ellipse(100, 50, 10, 10);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Controlling child window properties.</title>
      <link>https://forum.processing.org/two/discussion/16210/controlling-child-window-properties</link>
      <pubDate>Sat, 23 Apr 2016 17:29:58 +0000</pubDate>
      <dc:creator>AverageJoe</dc:creator>
      <guid isPermaLink="false">16210@/two/discussions</guid>
      <description><![CDATA[<p>In the example: Demos &gt; Tests &gt; MultipleWindows<br />
I would like to create a child window which does not close the main window when closed. The purpose is to have an inspection window which will be created for a short time, then closed, and then something else is inspected. My hunch is that it's something with JFrame if I'm not confused, but I probably am because I can't find anything.<br />
<br />
After using the G4P library, I've noticed that after about three to seven windows are created and closed in procession, my entire computer starts going very slowly, but my resource monitor shows nothing specific. So, I'm looking to build the windows from scratch to see if it's any different or if it's my computer.<br /></p>
]]></description>
   </item>
   <item>
      <title>Multiple Window as Clocks using JFrame class</title>
      <link>https://forum.processing.org/two/discussion/16154/multiple-window-as-clocks-using-jframe-class</link>
      <pubDate>Thu, 21 Apr 2016 09:14:25 +0000</pubDate>
      <dc:creator>blyk</dc:creator>
      <guid isPermaLink="false">16154@/two/discussions</guid>
      <description><![CDATA[<p>Hi as an experiment I have been trying to create a clock using JFrame where frame will be represented as one of the arm of the clock and they will move accordingly. I am also trying to display the second or minute or hour on the corresponding frame but I am not able to do so. Also I am not able to hide processing default window.</p>

<p>Problems</p>

<ol>
<li>Not able to display the text [second, minute or hour] on all the windows</li>
<li>Not able to hide default processing window</li>
<li>Not able to set background color for the all the windows</li>
</ol>

<p>Here is my code -</p>

<pre><code>    import com.sun.awt.AWTUtilities;
    import  java.awt.GraphicsDevice.*; // PC only
    import java.awt.Shape;
    import java.awt.AWTException;
    import java.awt.geom.*;
    //----------------------
    import java.awt.Frame; 
    import java.awt.Shape;
    //----------------------

    PFrame[] f = new PFrame[3]; 
    secondApplet[] s =new secondApplet[3];
    color[] c = new color[3];

    PFrame centerFrame;
    secondApplet centerApplet;

    int R = 200;
    int cx, cy;
    float secondsRadius;
    float minutesRadius;
    float hoursRadius;
    float clockDiameter;

    void setup() {
      size(100, 100);
      int radius = min(displayWidth, displayHeight) /4;
      secondsRadius = radius ;
      minutesRadius = radius ;
      hoursRadius = radius ;
      clockDiameter = radius;

      cx = displayWidth / 2;
      cy = displayHeight / 2;


      centerFrame = new PFrame(cx, cy);
      Shape centerShape = null;
      centerShape = new Ellipse2D.Float(0, 0, 10, 10);
      AWTUtilities.setWindowShape(centerFrame, centerShape);

      for (int i=0; i&lt;f.length; i++) {
        int x = (int)(R*cos(radians(i*360/3)));
        int y = (int)(R*sin(radians(i*360/3)));
        f[i] = new PFrame(x, y);
        Shape shape = null;
        shape = new Ellipse2D.Float(0, 0, 100, 100);
        AWTUtilities.setWindowShape(f[i], shape);
        c[i] = (color)random(#000000);
      }
    }

    void draw() { 
      background(0);



      int time=0;
      for (int i=0; i&lt;3; i++) {
        if (i==0) time = second();
        else if (i==1) time = minute();
        else if (i==2) time = hour();
        s[i].background(c[i]);
        s[i].fill(-1); 
        s[i].textAlign(CENTER);
        s[i].text(time, 50, 50);
        s[i].redraw();
      }

      float s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI;
      float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI; 
      float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI;

      println(s + " " + m + " " + h);

      f[0].setLocation(cx + (int)(cos(s)*secondsRadius), (int)(cy+sin(s)*secondsRadius));  
      f[1].setLocation(cx + (int)(cx + cos(m) * minutesRadius), (int)(cy + sin(m) * minutesRadius));
      f[2].setLocation(cx + (int)(cos(h) * hoursRadius), (int)(cy + sin(h) * hoursRadius));
    }

    public class PFrame extends Frame {
      public PFrame(int x, int y) {
        setBounds(x, y, 100, 100);
        for (int i=0; i&lt;3; i++) {
          s[i] = new secondApplet();
          add(s[i]);
          s[i].init(); 
          removeNotify(); 
          setUndecorated(true);
          addNotify();
          show();
        }
      }
    }

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

      public void draw() {
      }
    } 
</code></pre>
]]></description>
   </item>
   <item>
      <title>Multi display Issue</title>
      <link>https://forum.processing.org/two/discussion/13542/multi-display-issue</link>
      <pubDate>Tue, 17 Nov 2015 05:55:33 +0000</pubDate>
      <dc:creator>Heathbar121</dc:creator>
      <guid isPermaLink="false">13542@/two/discussions</guid>
      <description><![CDATA[<p>Hi, 
I have<a rel="nofollow" href="http://pastebin.com/BcDPfQMr#"> this</a> code but I need my video to display as a second window rather than over my map images. 
The video will be viewed on projectors and the map will be on a iMac
Any help would be greatly appreciated.</p>

<p>I tried combining my code above with <a rel="nofollow" href="http://stackoverflow.com/questions/32798606/how-to-create-more-than-one-window-of-a-single-sketch-in-processing">the second code on this page</a> but could seem to get it to display.</p>
]]></description>
   </item>
   </channel>
</rss>