Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

  • Error waited 5000ms

    Yes, definitely synchronized(this) if you want to synchronize with draw() otherwise they're not synchronized at all.

  • Concurrent Modification Exception trying to add objects on OSC event

    If you need to mutate a lot of different lists/state in response to OSC messages you can also put the OSC messages into a list and then synchronize on that list to take care of this issue across the whole sketch.

    import oscP5.*;
    import netP5.*;
    
    OscP5 oscP5;
    ArrayList oscMessageQueue = new ArrayList();
    
    void setup() {
      oscP5 = new OscP5(this, 12000);
    }
    
    void draw() {
      
      // take care of the OSC messages once per frame
      dispatchOSCMessages();
      
      // Do the rest of your rendering here, it won't be bothered by OSC messages showing up.
    }
    
    // Handle all the enqueued OSC messages at once.
    void dispatchOSCMessages() {
      synchronized(oscMessageQueue) {
        for(OscMessage message : oscMessageQueue) {
          // Do things here that require modifying lists or other actions
          // which should never happen half-way through the draw function.
        }
        
        // clear the list of messages.
        oscMessageQueue.clear();
      }
    }
    
    // Add the OSC messages to the queue to be handled later.
    void oscEvent(OscMessage message) {
      synchronized(oscMessageQueue) {
        oscMessageQueue.add(message);
      }
    }
    
  • How can I (quickly) retrieve video frames one at a time, indexed by time/frame number?

    I am trying to synchronize an animation and video and save the output as a new video. The animation is based on data collected at arbitrary times, roughly at 20 fps (but not close enough to look right at that speed). Therefore I need to tag the data with the time it is collected and display the corresponding frame of the video each time a new data point is loaded.

    It is simple to do this using Movie.jump(), but that function takes several seconds to complete, so rendering an entire video is intractably slow. I also tried using the jmcvideo library, but it only works with Processing 1.5.1 and doesn't display frames correctly.

    Is there another library or function that can load video frames quickly? Rendering in real-time is acceptable, but any slower will make the whole program useless. Thanks!

  • RPI CAMERA

    I want to display my camera without putting it to my draw

    This doesn't make sense to me. draw() is how you display things -- anything. You can't display your camera without displaying it.

    I must isolate the process of drawing the image background and the code of using the camera. I hope you understand what am I saying.

    Do you mean that you want to organize your code with functions?

    void draw(){
      drawBackground();
      drawCamera();
    }
    void drawBackground(){
      // background code here
    }
    void drawCamera(){
      // camera code here
    }
    

    ...or do you mean that you want the camera in a separate thread? I'm not sure that a camera thread would be a good idea -- you would still need to synchronize in order to draw().

  • Shape primitive flickering while multithreading

    Is there a reason you moved this to another thread?

    You can't modify and use variables from two different threads without synchronizing your logic. Otherwise, you get situations like yours where the data is changing while you're trying to render it.

    You need to synchronize your code so that you aren't changing the data while you're drawing it. But at that point, do you really need to be using different threads?

  • Processing Threads, Synchronization of Variables across threads!

    Unfortunately its not that simple.. The faceDetect method determines if a face is present and sets readyToStream to false and readyToCapture to false.. This happens inside the faceDetect() method.. So somehow I need to synchronize / track the boolean change happening across the other threads.. Hope I'm making sense!

  • Concurrent Modification Exception trying to add objects on OSC event

    DUDE!!! Rock and Roll :D:D:D that totally works. And thanks for the quick reply.

    I now see the implementation of the synchronized in the draw loop and the osc receiver. And basically that will synchronize any writing to or removing from the array? Very cool! Thanks.

  • Attaching directly to raw user input in library.

    Hi all.

    How can one build a Processing library that directly connects into the raw user input feed, as opposed to connecting to the standard Processing handlers?

    I am the writer of Hermes, a game engine for Processing. The concept behind the library is to build out a game engine system with the Processing drawing API used for rendering, but with our library handling the core game loop, threading model, entity system and input handling (to merge both user and network input). To accomplish the last point, we obtained access to the root Applet object and attached our input handler for mouse and keyboard directly to it. Attaching to the Processing handler didn't work, as the Processing handler queued events to synchronize with rendering; we needed events to go to an entirely different "logic" thread, which needs its own layer of queueing. Stacking the two two layers of buffering, adding latency to input handling.

    This, of course, has broken with the change to Processing v3, where Applet is no longer used. However, I haven't quite figured out what's happening with the user input and how to get direct access to it.

    Any tips would be appreciated, including that this is no longer possible.

    Thanks!

  • Concurrent Modification Exception trying to add objects on OSC event

    I'm designing this generative visuals system that uses OSC data from a musician to produce these kind of abstract "asteroids" in real time. I'm running into this Concurrent Modification Exception which I'm assuming has to do with the fact that the OSC Event is another thread (or something? happening alongside my draw loop) and so maybe when iterating through my asteroid objects an asteroid is added, causing an error. I thought the synchronize trick would work, no such luck. Any help is appreciated!

    Note: Just tried it with also protecting/removing the .remove() portion of the code, same error (although perhaps less frequent?)

    // OSC STUFF
    volatile boolean isBusy = false;
    
    /* incoming osc message are forwarded to the oscEvent method. */
    void oscEvent(OscMessage theOscMessage) {
        if (theOscMessage.addrPattern().equals("/peter/rhythm")) {
            if (!isBusy)
            asteroids.add(new Asteroid(0));
        }
    }
    
    
    // DRAW STUFF
    void wormhole() {
        pg.background(bgColor, bgTrans);
    
        // there are stars from last scene, animate those suckers
        for (Star s : stars) {
            s.display();
        }
    
        isBusy = true;
        // update, display asteroids
        synchronized (asteroids) {
            for (Asteroid a : asteroids) {
                a.update();
                a.display();
            }
        }
        isBusy = false;
    }
    
    
    // DELETING ASTEROIDS STUFF FROM DRAW() maybe this needs synch too?
      // destroy anything that is offscreen
      for (int i = asteroids.size() - 1; i >= 0; i--) {
        Asteroid a = asteroids.get(i);
        if (a.dead()) {
          asteroids.remove(i);
        }
      }
    
    
    // ASTEROID class
    float asteroidTrans = 120;  // global transparency modifier for asteroids
    
    class Asteroid {
      PVector pos;
      color cFill, cStroke;
    
      float r;  // rotation
      float rotateSpeed = .005;
    
      float sw = 2; //strokeWeight
    
      float ld = 5; // line distance
    
      float p;  // phase
      float pRate = .3;  // phase rate
      float pAdjust;  // use this number to add to s [or any other value)
    
      float speed = 1;
      float s = 1;  // starting size
      float growthRate = .05; // growth per frame
    
      int type = 0; // type of asteroid
    
      // properties
      // phase pulsates size of asteroid
      // corona gives it a circular outline
      // death color makes it change space bg color on impact w screen
    
      // behaviors
      boolean ROTATE, PHASE;
      // shape types
      boolean BOX, SPHERE, LINES, CORONA, TRI;
      // on death/ birth
      boolean DEATH_COLOR;
      // extras
    
      Asteroid(int type) {
        this.type = type;
    
        pos = new PVector(random(width), random(height), far);
    
        // randomize its initial rotation
        r = random(TWO_PI);
    
        switch (type) {
        case 0: // black cube
          cFill = color(0);
          cStroke = color(255);
          ROTATE = true;
          BOX = true;
          break;
        case 1: // colorful, pulsating circles, on death make bg that color
          sw = 0;
    
          // random colors
          cFill = color(random(255), random(255), random(255), random(20, 255));
          cStroke = cFill;
    
          ROTATE = true;
          PHASE = true;
          SPHERE = true;
          CORONA = true;
          DEATH_COLOR = true;
          break;
        case 2: // line creature..?
          LINES = true;
          PHASE = true;
          //CORONA = true;
          //pRate = .001;
          ld = 20;
          sw = 1;
          cStroke = color(255);
          break;
        case 3: // triangles
          TRI = true;
          ROTATE = true;
          PHASE = true;
          cFill = color(255);
          rotateSpeed = .01;
          break;
    
        }
    
      }
    
      void update() {
        // all asteroid types move towards you (and grow)
        pos.z += speed * hyperspaceModifier;
        s += growthRate * hyperspaceModifier;
    
        // rotating asteroids
        if (ROTATE) {
          r += rotateSpeed * hyperspaceModifier;
        }
    
        if (PHASE) {
          p += pRate; // inc phase
          pAdjust += sin(p) * .5;
        }
      }
    
      void display() {
    
        // TRIANGLE
        if (TRI) {
          pg.pushMatrix();
          pg.translate(pos.x, pos.y, pos.z);
          if (ROTATE) {
            pg.rotateZ(r);
          }
          pg.rotateX(3 * PI / 2);
          pg.stroke(255);
          if (PHASE) {
            float r = map(sin(p), -1, 1, 0, 255);
            float g = map(cos(p), -1, 1, 0, 255);
            float b = map(tan(p), -1, 1, 0, 255);
            cFill = color(r, g, b);
          }
          pg.fill(cFill);
    
          pg.beginShape(TRIANGLES);
          pg.vertex(-12, -12, -12);
          pg.vertex( 12, -12, -12);
          pg.vertex(   0,    0,  12);
    
          pg.vertex( 12, -12, -12);
          pg.vertex( 12,  12, -12);
          pg.vertex(   0,    0,  12);
    
          pg.vertex( 12, 12, -12);
          pg.vertex(-12, 12, -12);
          pg.vertex(   0,   0,  12);
    
          pg.vertex(-12,  12, -12);
          pg.vertex(-12, -12, -12);
          pg.vertex(   0,    0,  12);
          pg.endShape();
    
          //pg.triangle(0, -10, 8, 10, -8, 10);
          pg.popMatrix();
        }
    
        // LINE
        if (LINES) {
          pg.pushMatrix();
          pg.translate(pos.x, pos.y, pos.z);
          pg.stroke(cStroke);
          pg.strokeWeight(sw);
    
          int segments = 8;
    
          PVector[] linePV = new PVector[segments];
          linePV[0] = new PVector(0, 0, 0);
          for (int i = 1; i < segments; i++) {
            float x = cos( p + (segments / TWO_PI * i)) * ld * (i * .1);
            float y = sin( p + (segments / TWO_PI * i)) * ld * (i * .1);
            float z = linePV[i - 1].z - ld;
    
            linePV[i] = new PVector(x, y, z);
    
            pg.line(linePV[i - 1].x, linePV[i - 1].y, linePV[i - 1].z, x, y, z);
          }
    
          pg.popMatrix();
        }
    
        // CORONA
        if (CORONA) {
          pg.pushMatrix();
          pg.translate(pos.x, pos.y, pos.z);
          pg.stroke(cStroke, asteroidTrans);
          pg.noFill();
          pg.strokeWeight(sw + 4 + pAdjust);
          pg.ellipse(0, 0, (s + pAdjust) * 1.3, (s + pAdjust) * 1.3);
          pg.popMatrix();
        }
    
        // BOX
        if (BOX) {
          pg.pushMatrix();
          pg.translate(pos.x, pos.y, pos.z);
          if (ROTATE) rotate();
          pg.fill(cFill, asteroidTrans);
          pg.strokeWeight(sw);
          pg.stroke(cStroke);
          pg.box(s + pAdjust);
          pg.popMatrix();
        }
    
        // SPHERE
        if (SPHERE) {
          pg.pushMatrix();
          pg.translate(pos.x, pos.y, pos.z);
          pg.strokeWeight(sw);
          pg.stroke(cStroke);
          pg.fill(cFill, asteroidTrans);
          //pg.sphereDetail(7);
          //if (ROTATE) rotate();
          //pg.sphere(s + pAdjust);
          pg.ellipse(0, 0, s + pAdjust, s + pAdjust);
          pg.popMatrix();
        }
      }
    
      boolean dead() {
        // if object gets totally offscreen...
        if (pos.z > 1000) {
          // DEATH COLOR asteroids change bg color on impact
          if (DEATH_COLOR) {
            bgColor = cFill;
          }
          return true;  // destroy object
        } else {
          return false;
        }
      }
    
      // if this asteroid is a rotater
      void rotate() {
        pg.rotateY(r);
        pg.rotateZ(r * 2);
        pg.rotateX(r * 3);
      }
    }
    
  • Getting video jitter from webcam Capture

    Thank you! Initial tests seem to indicate that putting the synchronize armor around some of the for loops fixed it. I didn't realize add() could also cause these exceptions! GoToLoop, you are the best.

  • Multiscreen

    It would be easiest to use a single computer, since you don't have to synchronize communication between anything then. Just create a single application that stretches across multiple monitors.

    However, for huge displays, a single computer isn't enough. You can either try to upgrade your single computer, or you can buy multiple computers. Which one is cheaper really depends on what exactly you're trying to do.

    MostPixelsEver helps you do the synchronization between multiple computers. I wouldn't say it's necessarily cheaper, since the only reason you'd really use it is if you had multiple computers.

    It's really up to you which approach you take.

  • How to set values of a GUI element in Guido?

    Hey,

    I try to synchronize incoming OSC with the GUI of Guido to be able to use both to modify my sketch parameters. Unfortunately there is no documentation yet and no example for doing this.

    So for a start I simply wanted to figure out how to set values of a slider using the mouse. This is my attempt modifying the slider example of the library by adding a set() method to the Slider class:

    /**
     *    A slider
     *
     *    .. works with JavaScript mode since Processing 2.0a5
     */
    
    import de.bezier.guido.*;
    
    Slider slider;
    
    void setup ()
    {
        size(400, 400);
    
        // make the manager
    
        Interactive.make( this );
    
        // create a slider
    
        slider = new Slider( 2, 2, width-4, 16 );
    }
    
    void draw ()
    {
        background( 0 );
    
        fill( 255 - (slider.value * 255) );
        ellipse( width/2, height/2, 150, 150 );
        fill( slider.value * 255 );
        ellipse( width/2, height/2, 70, 70 );
        slider.set((float)mouseX);
    }
    
    public class Slider
    {
        float x, y, width, height;
        public float valueX = 0, value;
    
        Slider ( float xx, float yy, float ww, float hh ) 
        {
            x = xx; 
            y = yy; 
            width = ww; 
            height = hh;
    
            valueX = x;
    
            // register it
            Interactive.add( this );
        }
    
        // called from manager
        void mouseDragged ( float mx, float my )
        {
            valueX = mx - height/2;
    
            if ( valueX < x ) valueX = x;
            if ( valueX > x+width-height ) valueX = x+width-height;
    
            value = map( valueX, x, x+width-height, 0, 1 );
        }
    
        void draw () 
        {
            noStroke();
    
            fill( 100 );
            rect(x, y, width, height);
    
            fill( 120 );
            rect( valueX, y, height, height );
        }
    
        void set (float _value) {
            Interactive.set(this,"value",_value);
        }
    }
    

    But I only get Interactive.set() ... unable to find a field with that name in given target. How can I fix this?

    Thanks a lot!

  • 32bit application vs 64 bit application

    How do you make a movie? (BTW, it wasn't in the original question...)
    In Processing, now, you just have to export the frames to the hard disk and to make a movie out of them. So the framerate is rather irrelevant, unless you need to synchronize on something like sound.

  • Producer/Consumer model

    I can't figure out what's being asked! Async data structures are diff. stuff and each case has its own particular way to implement in order to reach highest performance & reliance!

    I guess ArrayBlockingQueue is a good option if 1 doesn't wanna use synchronize.
    Otherwise, ArrayDeque is much better than LinkedList! o->

  • Fractals

    Hi guys,

    does anyone have any tips on how to incorporate 3-D fractals? I've already managed to make a few 2-D ones show but I eventually want to get to a full 3D one whose variables I have control over because I want to synchronize it wit some audio. I'd love any recommendations on how to get myself started.

    Many thanks

  • Audiovisualizer fractals

    Hi guys,

    My project is a dynamic audio visualizer that creates graphical imagery and animation based on input audio signals. It will respond to varying components of frequency based intensity, meter, rhythmic qualities, and user selected parameters. Anyhow I wanted to incorporate fractals which responded to the above variables, I know I need a .obj and mtl file for 3-D objects. Otherwise I've already made my own 2-D fractals but rotating them and translating etc won't do it I'd much rather find some 3-D fractals. Does anyone know where I can find some so I can synchronize them with the music for the visualizer?

  • ConcurrentModificationException on synced lists...

    I have the skeleton of a very simple space invaders inspired game here...currently all the projectiles and enemies drawn on the screen are being kept in synchronized lists. I think I correctly obtained these from Collections.synchronizedList() on lines 11 and 12 of SpaceInvaders...but when the enemy list is edited in getCollision() (SpaceInvaders 94) there is a ConcurrentModificationException thrown...this code should be synchronized on both lists...there are synchronization blocks around the all of this method. Why is this exception being thrown? Any Ideas?

    OS: Windows 7 Processing Version: 2.2.1

    Code Files: SpaceInvaders:

    java.util.List enemies;
    java.util.List friendlyShots;
    Player player;
    Object lock;
    
    void setup () {
      size(720, 600, P2D);
    
      //Only friendly shots should be acessed by multiple threads simultaneously...but I was getting errors
      //and initialized both lists as synchronized.
      enemies = java.util.Collections.synchronizedList(new ArrayList<Enemy>());
      friendlyShots = java.util.Collections.synchronizedList(new ArrayList<Projectile>());
    
      //Setup the enemies array, uses two loops to place the enemies easily.
      synchronized(enemies) {
        player = new Player(360, 550);
        for (int i = 0; i < 10; i++) {
          for (int j = 0; j < 3; j++) {
            //ENEMY_SPACING is the space between each enemy, ENEMY_PAD is the space between the left side and the first enemy, ENTITY_SIZE is the size of an enemy, all in pixels.
            enemies.add(new Enemy(Enemy.ENEMY_SPACING*i + Enemy.ENTITY_SIZE*i + Enemy.ENEMY_PAD, Enemy.ENEMY_SPACING*j + Enemy.ENTITY_SIZE*j + Enemy.ENEMY_PAD, 0, j*10 + i));
          }
        }
      }
    }
    
    
    void draw() {
      background(0);
    
      //Update and draw the friendly shots
      synchronized(friendlyShots) {
        for (Object o : friendlyShots) {
          //Cast
          Projectile p = (Projectile) o;
          //Update, this does collision detection, see Projectile.update() and collidingWith(boolean enemy, Entity projectile) below.
          p.update();
          //Draw
          render(p.getShape(), p.getX(), p.getY());
          println("Rendered Projectile");
        }
      }
    
      //Update and draw the enemies.
      synchronized(enemies) {
        for (Object o : enemies) {
          //Cast
          Enemy e = (Enemy) o;
          //Update, this is empty for now.
          e.update();
          //Draw
          render(e.getShape(), e.getX(), e.getY());
          println("Rendered Enemy");
        }
      }
    
      //Update the player
      player.update();
      //Render the player
      render(player.getShape(), player.getX(), player.getY());
    
      //If the mouse is too far to the right of the player, move the player right, move the player left if the inverse is true, otherwise don't move the player.
      if (mouseX > player.getX() + 5) {
        player.goRight();
      } else if (mouseX < player.getX() - 5) {
        player.goLeft();
      } else {
        player.stop();
      }
    }
    
    void mousePressed() {
      //This should be handled right after draw...but just in case let's synchronize.
      synchronized(friendlyShots) {
        //Add new projectile to the projectile array.
        friendlyShots.add(new Projectile(player.getX(), player.getY(), Projectile.FRIENDLY));
      }
    }
    
    //When this is not commented I get a concurrent modification exception from code here...but it should be synchronized right?
    //This is called by the projectile update function.
    
    boolean collidingWith(boolean enemy, Entity projectile) {
      float x = projectile.getX();
      float y = projectile.getY();
      boolean returnVal = false;
    
      if (enemy) {
        synchronized(enemies) {
          for (Object o: enemies) {
            println("Looking through enemies");
            Enemy e = (Enemy) o;
            if (abs(x - e.getX()) < Enemy.ENTITY_SIZE/2&&abs(y - e.getY()) < Enemy.ENTITY_SIZE) {
              enemies.remove(e.getID());
              returnVal = true;
            }
          }
        }
      }
      return returnVal;
      //TODO: Put player collision detection.
    }
    
    //Renders a shape
    void render(PShape s, float x, float y) {
      pushMatrix();
      translate(x, y);
      shape(s);
      popMatrix();
    }
    

    Entity:

    /* This is the base class for all the moving things on the screen, player, projectile and enemy.*/
    
    public abstract class Entity {
      public static final byte STOP = 0;
      public static final byte NORTH = 1;
      public static final byte SOUTH = 2;
      public static final byte EAST = 3;
      public static final byte WEST = 4;
    
      private float x, y;
      private float speed;
    
      protected byte movement;
    
      protected PShape s;
    
      protected Entity (float x, float y, float speed) {
        this.x = x;
        this.y = y;
        this.speed = speed;
        movement = STOP;
      }
    
      public abstract void update();
    
      protected Entity () {
        this(0, 0, 0);
      }
    
      public abstract PShape getShape();
    
      public void setSpeed(float speed) {
        this.speed = speed;
      }
    
      public float getX() {
        return x;
      }
    
      public float getY() {
        return y;
      }
    
      public void setX(float x) {
        this.x = x;
      }
    
      public void setY(float y) {
        this.y = y;
      }
    
      public void incXBy(float dx) {
        x += dx;
      }
    
      public void incXBySpeed(boolean invert) {
        if(invert){
          incXBy(-speed);
        }
        else {
          incXBy(speed);
        }
      }
    
      public void incYBy(float dy) {
        y += dy;
      }
    
      public void incYBySpeed(boolean invert) {
        if(invert){
          incYBy(-speed);
        }
        else {
          incYBy(speed);
        }
      }
    }
    

    Enemy:

    public class Enemy extends Entity {
      public static final int TYPE_0 = 0;
      public static final int TYPE_1 = 1;
      public static final int TYPE_2 = 2;
    
      public static final int ENEMY_SPACING = 40;
      public static final int ENTITY_SIZE = 30;
      public static final int ENEMY_PAD = 45;
    
      private int type;
      private int id;
    
      public Enemy(float x, float y, int type, int id) {
        super(x, y, 1);
        this.type = type;
        this.id = id;
    
        s = createShape();
        s.beginShape();
        s.noStroke();
        s.fill(255);
        s.vertex(-15, 0);
        s.vertex(15, 0);
        s.vertex(15, 30);
        s.vertex(7, 30);
        s.vertex(7, 20);
        s.vertex(-7, 20);
        s.vertex(-7, 30);
        s.vertex(-15, 30);
        s.endShape(CLOSE);
      }
    
      public int getID() {
        return id;
      }
    
      @Override
      public void update(){}
    
      public PShape getShape() {
        return s;
      }
    }
    

    Projectile:

    public class Projectile extends Entity {
      public static final int FRIENDLY = 0;
      public static final int ENEMY = 1;
    
      private int side;
    
      public Projectile(float x, float y, int side) {
        super(x, y, 10);
        this.side = side;
        if (side != FRIENDLY) {
          super.setSpeed(5);
        }
    
        s = createShape();
        s.beginShape();
        s.noStroke();
        s.fill(255);
        s.vertex(-5, 0);
        s.vertex(5, 0);
        s.vertex(5, 20);
        s.vertex(-5, 20);
        s.endShape(CLOSE);
      }
    
      @Override
      public void update() {
        //If this is a friendly projectile...
          if (side == FRIENDLY) {
            //...make it go up...
            super.incYBySpeed(true);
            //...and check if it's coliding with enemies.
            if (collidingWith(true, this)) {
              //if it collides remove it...still should be synchronized since it's called from draw.
              friendlyShots.remove(this);
            }
          }
          else {
            super.incYBySpeed(false);
          }
      }
    
      @Override
      public PShape getShape() {
        return s;
      }
    }
    

    And if you need it, Player:

    public class Player extends Entity {
    
      public Player(float x, float y) {
        super(x, y, 5);
        s = createShape();
        s.beginShape();
        s.fill(255);
        s.noStroke();
        s.vertex(-25, 50);
        s.vertex(25, 50);
        s.vertex(0, 0);
        s.endShape(CLOSE);
      }
    
      @Override
      public void update(){
        switch(movement) {
          case Entity.EAST:
            incXBySpeed(false);
            break;
          case Entity.WEST:
            incXBySpeed(true);
            break;
          case Entity.STOP:
            break;
          default:
            println("The player shouldn't be moving any other direction than east or west!!! What's going on?");
        }
      }
    
      @Override
      public PShape getShape() {
        return s;
      }
    
      public void goRight() {
        movement = Entity.EAST;
      }
    
      public void goLeft() {
        movement = Entity.WEST;
      }
    
      public void stop() {
        movement = Entity.STOP;
      }
    }
    

    And finally, the stack trace:

    java.lang.RuntimeException: java.util.ConcurrentModificationException
        at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
        at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)
        at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206)
        at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
        at javax.media.opengl.Threading.invoke(Threading.java:191)
        at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:541)
        at processing.opengl.PJOGL.requestDraw(PJOGL.java:688)
        at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1651)
        at processing.core.PApplet.run(PApplet.java:2256)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
        at java.util.ArrayList$Itr.next(Unknown Source)
        at SpaceInvaders.collidingWith(SpaceInvaders.java:105)
        at SpaceInvaders$Projectile.update(SpaceInvaders.java:325)
        at SpaceInvaders.draw(SpaceInvaders.java:52)
        at processing.core.PApplet.handleDraw(PApplet.java:2386)
        at processing.opengl.PJOGL$PGLListener.display(PJOGL.java:862)
        at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:665)
        at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:649)
        at javax.media.opengl.awt.GLCanvas$10.run(GLCanvas.java:1289)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1119)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:994)
        at javax.media.opengl.awt.GLCanvas$11.run(GLCanvas.java:1300)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$200(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
    

    If there's anything else needed or the formatting is wrong (I'm new here) I can edit my post, thanks for any help!

  • Threads, draw(), asynctask with big drawings?

    Hi, The question is a bit hard to formulate, but here is my problem: I am doing a cell-based simulation and want to display the states of the so-called cells on a grid using color codes. In Java mode, it's quite fast and I have used the architecture below:

    • in setup(): create the cells (an Arraylist of cells), start a thread("computation"), and call noLoop();

    • in the method computation(): update the state values of all cells, and, at the end, call redraw();

    • in draw(): a "for" loop in which I call the draw() for each cell.

    It did not bother me and basically I was happy that the simulation time was faster than the real time.

    I tried to port it to Android (I am testing it on a Galaxy S5), and now it is much slower. I guess it is because of the for loop in the draw(), so I tried:

    • putting this "for" loop in another thread(), but then everything bugs

    • putting this "for" loop in a class inheriting AsyncTask: it works but the display is messed up.

    I guess i need to put some "synchronize" here and there, but I am always confused on how to do that.

    Any help?

    Thanks.

  • Using Capture() with G4P. Urgent Help Please!

    Yea my timer uses millis() but delay() helps to synchronize it a bit. But I also read on another forum not to use it so i will tweak it with millis(). Your post was helpful. Thanks.

  • Using Capture() with G4P. Urgent Help Please!

    Yes, the hardest part has been getting the timing right. I have been trying it with flags and delay() so just a bit of tweaking is necessary. I think for the most part I got the pics to synchronize.

    And I haven't looked at pre() but thanks! I will check up on the documentation to see if it fits my project.

    Appreciate all the help :)