Dunno what thread you're talking about but in case you just need a sketch with lots of particles i thought i'd share this sketch that i made some months ago. 200k particles at 60 fps is fun :)
however adding physics slows it down like a mofo
- import processing.opengl.*;
- import javax.media.opengl.*;
- import java.nio.FloatBuffer ;
- import javax.media.opengl.glu.*;
- import com.sun.opengl.util.*;
- FloatBuffer fb;
- class Particle {
- public PVector pos;
- PVector vel;
- float speed;
- Particle(PVector _pos,PVector _vel,float _speed) {
- pos = _pos;
- vel = _vel;
- speed = _speed;
- vel.normalize();
- vel.mult(speed);
- }
- void tick() {
- pos.add(vel);
- if(pos.x > width||pos.x<0) {
- vel.x = -vel.x;
- }
- if(pos.y > width||pos.y<0) {
- vel.y = -vel.y;
- }
- }
- }
- class ParticleSystem{
- ArrayList<Particle> particles;
- public int numOf;
- ParticleSystem(){
- particles = new ArrayList<Particle>();
- numOf = 0;
- }
- void add(Particle p){
- if(numOf*2 <1000000){
- particles.add(p);
- numOf++;
- }
- }
- void tick(){
- if(numOf ==0) return;
-
- for(Particle p:particles){
- p.tick();
- fb.put(p.pos.x);
- fb.put(p.pos.y);
- }
- fb.rewind();
- PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
- GL gl = pgl.beginGL();
- gl.glVertexPointer(2,GL.GL_FLOAT,0,fb);
- gl.glDrawArrays(GL.GL_POINTS,0,numOf);
- pgl.endGL();
- println(numOf);
- }
- }
- ParticleSystem ps;
- void setup(){
- size(800,800,OPENGL);
- background(0);
- noStroke();
- ps = new ParticleSystem();
- fb = BufferUtil.newFloatBuffer(1000000);
- PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
- GL gl = pgl.beginGL();
- gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
- gl.glColor4f(1.0,1.0,1.0,0.5);
- gl.glPointSize(5);
- pgl.endGL();
- }
- void draw(){
- frame.setTitle(str(frameRate));
- background(0);
- if(mousePressed){
- for(int i = 0; i< 1000;i++){
- ps.add(new Particle(new PVector(random(width),random(height)),new PVector(random(-10,10),random(-10,10)),5));
- }
- }
- ps.tick();
- }
edit: come to think of it
this might be what you're looking for (obviously that is where i found the way of rendering tons of particles very quickly)